Data types specific to engines

3 views
Skip to first unread message

Jonas

unread,
Jul 19, 2007, 7:44:04 AM7/19/07
to sqlalchemy
I think that the data types are too generic and would be interesting
that an user could choose data types specific of a data base engine to
take advantage of it better.

As you can see for PSQL engine [1] there are many data types that
could be very useful. And so with other major engines.

[1] http://www.postgresql.org/docs/8.2/static/datatype.html

Michael Bayer

unread,
Jul 19, 2007, 12:53:11 PM7/19/07
to sqlalchemy
this capability already exists.

For example, if you want specific SQL types, those are implemented.
if you want specfically a CHAR column, use types.CHAR. Or VARCHAR,
use types.VARCHAR. Other implemented SQL types are TIMESTAMP, CLOB
and BLOB.

But that's not all. For types that are totally specific to a certain
database, those are available as well, within the module for each
database.

for example,

import sqlalchemy.databases.mysql as mysql
import sqlalchemy.databases.postgres as postgres

mysql.MSEnum -> mysql's ENUM type
mysql.MSBigInteger -> mysql's BIGINTEGER type
postgres.PGInet -> Pg's INET type
postgres.PGArray -> Pg's ARRAY type

We also have a newer class of types that are generic, but will use a
more specific DB type if one is available. An example is the Interval
type. This will use a regular date column on most databases,
subtracting the difference from 1/1/1970 to get the result. But on
postgres, it uses the PGInterval type, which is PG's INTERVAL type.

Michael Bayer

unread,
Jul 19, 2007, 1:11:41 PM7/19/07
to sqlalchemy
i just put up a little bit of new docs to this effect.

Jonas

unread,
Jul 23, 2007, 7:08:54 PM7/23/07
to sqlalchemy
Thank you very much! :)
Reply all
Reply to author
Forward
0 new messages