Informix reflecttable still references table.owner. Fails to autoload metadata.

Issue #1297 resolved
Former user created an issue

Test Case

from sqlalchemy import create_engine
from sqlalchemy import Table
from sqlalchemy import MetaData

import os
os.environ['INFORMIXSERVER']('INFORMIXSERVER') = 'myserver'

engine = create_engine("informix://user:pass@libname/db")
metadata = MetaData(bind=engine)

table = Table( 'mytable', metadata, autoload=True)

results in the following stack trace.

python sqlalchemyinformixtestcase.py 
Traceback (most recent call last):
  File "sqlalchemyinformixtestcase.py", line 11, in <module>
    table = Table( 'mytable', metadata, autoload=True)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/schema.py", line 113, in __call__
    return type.__call__(self, name, metadata, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/schema.py", line 241, in __init__
    _bind_or_error(metadata).reflecttable(self, include_columns=include_columns)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/base.py", line 1265, in reflecttable
    self.dialect.reflecttable(conn, table, include_columns)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/databases/informix.py", line 256, in reflecttable
    if table.owner is not None:
AttributeError: 'Table' object has no attribute 'owner'

I have a patch that I will post up after I make sure it all works.

Comments (5)

  1. Former user Account Deleted

    Replying to zzzeek:

    can you please supply patches for the trunk as well as source:/sqlalchemy/branches/rel_0_6 ? we have no way of testing informix here....thanks. Hi,[BR]

    recently I have developed a simple application with sqlalchemy (0.5.2) which must run both with PostgreSQL and Informix (IDS 11.10.UC2). The application takes advantage of ORM and database reflection but does not generate the schema itself. I have patched databases/informix.py in order to have my application working. In detail I have applied the following changes:[BR]

    • Added basic support for DATETIME YEAR TO FRACTION(3) type[BR]

    • Added new types 40 (LVARCHAR) and 41 (BOOLEAN)[BR]

    • Changed the way last inserted serials are restrieved[BR]

    • Use of ''table.schema'' instead if ''table owners''[BR]

    • Got rod of ''visit_clauselist'' method which prevented a correct creation of WHERE clause in case of multiple conditions[BR]

    I don't believe in future I will have more opportunities to work with Informix any more, hence I am posting here my version of informix.py hoping it could be useful to other developers.[BR]

    Beste Regards[BR]

    Paolo

  2. Log in to comment