Ok, the following lines of SA/Python:
# the constructor sets
# sa.engine.dialect.set_default_schema_name('DataTables')
# full code below
sa = data.config.db.sqlalchemy(schema="DataTables", echo=True)
# leaving off schema='DataTables' generates invalid SQL
ke_contracts = Table('KEContracts', sa.metadata, autoload=True)
result = ke_contracts.select(ke_contracts.c.refnum == r).execute()
will yield Invalid object name 'KEContracts'
but adding schema="DataTables" like so:
ke_contracts = Table('KEContracts', sa.metadata, autoload=True,
schema="DataTables")
======
class sqlalchemy:
def __init__(self, ip="224.55.182.2", db="DATA",
schema="DataTables", echo=True):
conn_url = "mssql://xx:[EMAIL PROTECTED]:1433/%s" % (ip, db)
print "conn_url", conn_url
self.engine = create_engine(conn_url)
self.engine.dialect.set_default_schema_name(schema)
self.engine.echo=echo
self.metadata = BoundMetaData(self.engine)
results in a successful select...
to me this implies that setting the default schema name on the engine
does not make the proper schema qualifications on the SQL...
it boils down to the FROM part being
FROM DataTables.KEContracts
instead of
>From KEContracts
and one working and the other yielding invalid object name.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---