Bingo, that's exactly it. It was being brought out by nosetests/logging, so it always showed up in the query log for sqlalchemy for tests. Manually hitting the service URL multiple times only issues the SELECT default_schema_name query once as you said.
Thanks, -Phil On Wednesday, April 10, 2013 3:20:06 PM UTC-7, Michael Bayer wrote: > > default schema is only queried the first time an Engine is used. it > sounds like you're making an Engine per Session, which is an antipattern. > Make just one engine per database URL per app. > > > On Apr 10, 2013, at 5:34 PM, Philip Russell > <[email protected]<javascript:>> > wrote: > > Hi, apologies if this has been asked before (didn't see so in search) > > Background: > - Python 2.7 > - SQLAlchemy 0.8.2 > - pyodbc 3.0.6 > - FreeTDS 0.82-1 > > Connecting to MSSQL, and have a bunch of explicit schema settings in my > Model classes: > > class MyTable(Base): > __tablename__ = 'my_table' > > __table_args__ = {"schema" : "dbo"} > .... > > When I issue anything in a Session, it always issues the following first: > > 2013-04-10 13:54:38,154 INFO sqlalchemy.engine.base.Engine SELECT > user_name() > 2013-04-10 13:54:38,157 INFO sqlalchemy.engine.base.Engine () > 2013-04-10 13:54:38,177 INFO sqlalchemy.engine.base.Engine > SELECT default_schema_name FROM > sys.database_principals > WHERE name = ? > AND type = 'S' > > My question is, is the above necessary? I'm explicitly setting the schema > for each Base model, so I'd expect it wouldn't need to know the default > schema. > > If the query isn't necessary, is there a way to prevent it from being > issued? > > Thanks, > > -Phil > > -- > 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] <javascript:>. > To post to this group, send email to [email protected]<javascript:> > . > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
