Skip to content Skip to sidebar Skip to footer

How To Find Sqlalchemy Generic Datatype From Vendor-specific Datatype

Given a vendor-specific SQLAlchemy datatype, such as sqlalchemy.dialects.postgresql.INTEGER, what is the best way to find the generic SQLAlchemy datatype that best corresponds to t

Solution 1:

This feature has been added to SQLAlchemy 1.4

https://github.com/sqlalchemy/sqlalchemy/pull/5714

Example:

from sqlalchemy.dialects.mssql import DATETIME2
mssql_type = DATETIME2()
print(type(mssql_type))  # <class 'sqlalchemy.dialects.mssql.base.DATETIME2'>
generic_type = mssql_type.as_generic()
print(type(generic_type))  # <class 'sqlalchemy.sql.sqltypes.DateTime'>

Post a Comment for "How To Find Sqlalchemy Generic Datatype From Vendor-specific Datatype"