SQL is as type-safe as the DB engine allows it to be. PostgreSQL is type-safe. Extracting these types and making them available and usable in your lang-of-choice at compile time is a different problem though.
Bringing this type information at "compile-time" into your language of choice where you embed your queries can also be done but is a harder problem. There is good progress in that sphere but it is still in it is infancy.
The GraphQL eco-system for example, has this figured out using code generators. A similar thing can be done with DBs.
def do(s: int) -> str:
return 5
print(do("123"))
Python is duck-typed. Wrong types aren't detected until they fail to quack correctly.