On Jul 16, 2014, at 3:33 AM, Tomas Dabašinskas <[email protected]> wrote:
> Hi, > I'm trying to use sqlalchemy on virtual teiid database which emulates > posgress. My virtual database requires schema name on select queries, for > exampe: > > SELECT "Bugzilla".bugs.bug_id AS "Bugzilla_bugs_bug_id", > "Bugzilla".bugs.short_desc AS "Bugzilla_bugs_short_desc" FROM "Bugzilla".bugs > where "Bugzilla".bugs.bug_id=1115513; > > so I'm adding schema to my declarative_base: Base = > declarative_base(metadata=MetaData(schema="Bugzilla")) for my Bugs table I'm > using: > > class Bug(Base): > __tablename__ = "bugs" > > bug_id = Column(Integer, primary_key=True) > short_desc = Column(String) > > > If I run a query: > bugs = DBSession.query(Bug).filter_by(bug_id=1115513).all() > I'm getting an error saying NoSuchColumnError: "Could not locate column in > row for column 'bugs.bug_id'" > I believe this is because select query that is generated looks like this: > 2014-07-16 07:09:53,190 INFO [sqlalchemy.engine.base.Engine][Dummy-2] SELECT > "Bugzilla".bugs.bug_id AS "Bugzilla_bugs_bug_id", "Bugzilla".bugs.short_desc > AS "Bugzilla_bugs_short_desc" FROM "Bugzilla".bugs WHERE > "Bugzilla".bugs.bug_id = 1115513 > > It appears as if sqlalchemy knows about the scheme on select and forgets > about it when result is returned. > > How do I make sure sqlalchemy expects columns: bugzilla_bugs_bug_id > bugzilla_bugs_short_desc not bugs.bug_id? > > Here's paste of the error: http://p.defau.lt/?oB9HEsHyPRaLveruhu9GMw > > Many thanks for your help is there a dialect for Telid (which I believe is internal to a particular company…. which I might work for) ? I’ve seen this database before, and if its SQL needs are this unusual, it probably needs its own dialect. I’ve said as much to some folks on IRC. In this case special logic is probably needed at the compiler level as well as as the cursor.description level to work around this. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
