On 1/26/06, Runar Petursson <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I ran into a similar problem when I started test sql alchemy out.  The
> issue is that there isn't any information about Sequence columns in
> the information_schema standard.  My database interface is mssql
> (which I'll at some point post to the project, after some more
> testing), so I had to write a database specific introspection routine.
>  In SQL Server you can find out using sp_columns, so a method on my
> MSSQL Engine Looks like this:
>
>     def reflecttable(self, table):
>         ischema.reflecttable(self, table, ischema_names)
>
>         # Also run an sp_columns to check for identity columns:
>         cursor = table.engine.execute("sp_columns " + table.name, {})
>         while True:
>             row = cursor.fetchone()
>             if row is None:
>                 break
>             col_name, type_name = row[3], row[5]
>             if type_name.endswith("identity"):
>                 ic = table.c[col_name]
>                 # Set the Default of the column to a Sequence instance
>                 ic.default = schema.Sequence(ic.name + '_identity')
>                 break

This can be a solution, but looking at reflecttable code in
databases/postgres I see that everything is wrapped in a dict:

 pg2_ischema_names = {
    'integer' : PGInteger,
    'bigint' : PGInteger,
    'character varying' : PGString,
    'character' : PGChar,
    'text' : PGText,
    'numeric' : PGNumeric,
    'float' : PGFloat,
    'real' : PGFloat,
    'double precision' : PGFloat,
    'timestamp with time zone' : PG2DateTime,
    'timestamp without time zone' : PG2DateTime,
    'bytea' : PGBinary,
    'boolean' : PGBoolean,
}

without any other check.
I don't know how to implement this for PG without breaking the type
system in use. AFAIK a Sequence isn't even a sqlalchemy.types (in fact
it isn't a type, just a an integer with a "default").
Am I missing something ? Any suggestion is highly appreciated.

TIA,
  ngw


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to