Hi everybody:

I've begun work on a database engine for MS-SQL (if anyone else is working on this, please let me know ASAP).

One of the issues I've run into is that attempting to do table reflection generates an internal query for which MSSQL seems to require a table alias.

The query, from information_schema.py is:

    s = select([columns],
        sql.and_(columns.c.table_name==table.name, columns.c.table_schema==current_schema)
        order_by=[columns.c.ordinal_position])

which for a table named 'SysParms', would generate the following query:

SELECT columns.table_schema, columns.table_name, columns.column_name, columns.is_nullable, columns.data_type, columns.ordinal_position, columns.character_maximum_length, columns.numeric_precision, columns.numeric_scale, columns.column_default
FROM information_schema.columns
WHERE columns.table_name = 'SysParms' AND columns.table_schema = 'dbo' ORDER BY columns.ordinal_position

which then fails with a string of:

Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'columns' does not match with a table name or alias name used in the query.

Changing the FROM clause in the query to:

FROM information_schema.columns AS columns

Fixes things.

Now, how do I force the query generator to use a table alias? I've tried using:

 columns = columns.alias('columns')

Which then fails with a "no for clause" error

Help?

Thanks,
Rick

Reply via email to