Re: [sqlalchemy] Firebird is no way to implement UPDATE OR INSERT

2016-06-28 Thread uralbash
Thanks, In general, API for creation of custom ClauseElements and compilers 
will solve my problem

понедельник, 27 июня 2016 г., 19:12:05 UTC+5 пользователь Mike Bayer 
написал:
>
> not currently, and we don't actually spend much time working on the 
> Firebird dialect (would love if someone could come take it over).   Your 
> best bet would be working with custom compilation rules described in 
> http://docs.sqlalchemy.org/en/latest/core/compiler.html . 
>
>
>
> On 06/27/2016 07:47 AM, uralbash wrote: 
> > 
> > Is there a way to construct a query "UPDATE OR INSERT" for firebird 
> > like Postgres "INSERT...ON CONFLICT (Upsert)" 
> > (
> http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#insert-on-conflict-upsert)?
>  
>
> > 
> > 
> > Firebird docs 
> > http://www.firebirdsql.org/refdocs/langrefupd25-update-or-insert.html 
> > 
> > -- 
> > 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 sqlalchemy+...@googlegroups.com  
> > . 
> > To post to this group, send email to sqlal...@googlegroups.com 
>  
> > . 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Mike Bayer



On 06/28/2016 12:07 PM, Martijn van Oosterhout wrote:



On 28 June 2016 at 15:47, Mike Bayer > wrote:



On 06/28/2016 09:09 AM, Martijn van Oosterhout wrote:


That sqlite reference looks a bit weird, did I miss some
initialisation
somewhere?


It looks like the @compiles system is in place, which SQLAlchemy
does not use internally.  that wasn't in your code example but
that's likely where the exception is raised from.


Bingo! This is some cruft from prehistory of this project, not sure how
exactly it gets loaded, but adding this to the script triggers it reliably:

from sqlalchemy.ext.compiler import compiles

@compiles(ARRAY, "sqlite")
def compile_binary_sqlite(type_, compiler, **kw):
return "STRING"

Now, in my eyes this should have no effect if you're not using sqlite,
but there is obviously something going on. I've verified that this does
not fail on 1.0.0. At least now I can continue testing 1.1.0.


well that's a regression on our end, then.




Have a nice day,
--
Martijn van Oosterhout >
http://svana.org/kleptog/

--
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 sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Adding a shutdown session to the documentation

2016-06-28 Thread Jonathan Vanasco
I suggest a github/bitbucket repo (and possibly a pypi release), then link 
off the wiki.

using those other systems gives a sense of version control/timeliness and 
is much easier to copy from than wiki text.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Martijn van Oosterhout
On 28 June 2016 at 15:47, Mike Bayer  wrote:

>
>
> On 06/28/2016 09:09 AM, Martijn van Oosterhout wrote:
>
>>
>> That sqlite reference looks a bit weird, did I miss some initialisation
>> somewhere?
>>
>
> It looks like the @compiles system is in place, which SQLAlchemy does not
> use internally.  that wasn't in your code example but that's likely where
> the exception is raised from.
>
>
Bingo! This is some cruft from prehistory of this project, not sure how
exactly it gets loaded, but adding this to the script triggers it reliably:

from sqlalchemy.ext.compiler import compiles

@compiles(ARRAY, "sqlite")
def compile_binary_sqlite(type_, compiler, **kw):
return "STRING"

Now, in my eyes this should have no effect if you're not using sqlite, but
there is obviously something going on. I've verified that this does not
fail on 1.0.0. At least now I can continue testing 1.1.0.

Have a nice day,
-- 
Martijn van Oosterhout  http://svana.org/kleptog/

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Adding a shutdown session to the documentation

2016-06-28 Thread Mike Bayer



On 06/28/2016 11:34 AM, Martin Häcker wrote:

Hi there,

we're using sqlalchemy from within a tornado application to access the
database. To prevent us from accidentally stopping the single threaded
server we adopted a usage pattern of sqlalchemy where we use it during
startup to load various objects from the db, and then use background
threads to load more as required.

Since we wanted an easy way to get errors when we accidentally break
this pattern, we created a session that will raise when used and
subclassed the ThreadLocalRegistry to make it easy to use it.

Thus now Database access only works like this:

with DatabaseAccess():
   # do something to access the db

and is nicely explicit and raises otherwise.

We'd like to open source this (~100 loc + tests) perhaps as part of
sqlalchemy or the wiki? What do you think, would this be useful to somebody?


I'm not sure I'm understanding what it looks like when you "accidentally 
break" the pattern.  If I could see more of what we're talking about 
that would help, though it sounds like this is an async-oriented use 
case.   That's fine but external projects for these kinds of things make 
life a lot easier for me, including it under SQLAlchemy main means I 
take on the maintenance / support burden.







Best regards,
Martin Häcker

--
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 sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Adding a shutdown session to the documentation

2016-06-28 Thread Martin Häcker
Hi there,

we're using sqlalchemy from within a tornado application to access the 
database. To prevent us from accidentally stopping the single threaded 
server we adopted a usage pattern of sqlalchemy where we use it during 
startup to load various objects from the db, and then use background 
threads to load more as required.

Since we wanted an easy way to get errors when we accidentally break this 
pattern, we created a session that will raise when used and subclassed the 
ThreadLocalRegistry to make it easy to use it.

Thus now Database access only works like this:

with DatabaseAccess():
   # do something to access the db

and is nicely explicit and raises otherwise.

We'd like to open source this (~100 loc + tests) perhaps as part of 
sqlalchemy or the wiki? What do you think, would this be useful to somebody?

Best regards,
Martin Häcker

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] with_session and subquery loading

2016-06-28 Thread Mike Bayer



On 06/28/2016 10:39 AM, Michael Williamson wrote:



On Tuesday, June 28, 2016 at 2:57:08 PM UTC+1, Mike Bayer wrote:



On 06/28/2016 05:28 AM, mic...@healx3.com  wrote:
> Hello! I sometimes find it more convenient to create to construct a
> query without a session, and then to add the session at the end using
> `with_session`. In particular, when constructing non-trivial queries,
> not having to pass the session around means one less argument to
manage.
> However, this doesn't seem to work when using subquery loading,
> resulting in the error `AssertionError: Subquery session doesn't
refer
> to that of our context. Are there broken context caching schemes
being
> used?`.
>
> Is there a sensible way to get the subqueries to use the same
session,
> or is the answer just to always construct queries with the session?


that assertion only applies to when the internal QueryContext is being
re-used, as is the case with baked query loading.  The QueryContext
itself created during the _compile_context() phase will contain
references to the Session within the subquery eager loaders.   As long
as you don't do anything with your original query other than call
with_session(), there's no error I can reproduce, e.g.:

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class A(Base):
 __tablename__ = 'a'
 id = Column(Integer, primary_key=True)
 bs = relationship("B")

class B(Base):
 __tablename__ = 'b'
 id = Column(Integer, primary_key=True)
 a_id = Column(ForeignKey('a.id '))

e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

s = Session(e)
s.add_all([A(bs=[B(), B()]), A(bs=[B(), B()])])
s.commit()

q1 = Session().query(A).options(subqueryload(A.bs))

for sess in [Session(e), Session(e), Session(e)]:
 for a in q1.with_session(sess):
 print a, a.bs 



Please work up an example showing how you're getting that result,
thanks!


Thanks for the quick reply, and apologies for not providing an example
in the first place. I think I worked out the issue: we've wrapped up the
session:

class TransactionalSession(object):
def __init__(self, session):
self._session = session

def __enter__(self):
return self

def __exit__(self, exception_type, exception, traceback):
if exception is None:
self._session.commit()
else:
self._session.rollback()
self._session.close()

def __getattr__(self, key):
return getattr(self._session, key)

so when we try running the queries with subquery loading (for instance,
as in your example, but with `TransactionalSession(Session(e))`), the
session on `subq` is the underlying session, while the session on
`context` is our own wrapped session. So, presumably the saner way of
doing this would be either to use the underlying session directly, or to
subclass `Session`?


I'd subclass, but that pattern is already built into Session itself:

with my_session.transaction:
   # code

I guess the docs don't really point this out.  Another recipe that is 
better than wrapping is to use a function, that's in the docs:


from contextlib import contextmanager

@contextmanager
def session_scope():
"""Provide a transactional scope around a series of operations."""
session = Session()
try:
yield session
session.commit()
except:
session.rollback()
raise
finally:
session.close()


def run_my_program():
with session_scope() as session:
ThingOne().go(session)
ThingTwo().go(session)









>
> Thanks
>
> Michael
>
> --
> 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 sqlalchemy+...@googlegroups.com 
> .
> To post to this group, send email to sqlal...@googlegroups.com

> .
> Visit this group at https://groups.google.com/group/sqlalchemy
.
> For more options, visit https://groups.google.com/d/optout
.

--
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 sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more 

Re: [sqlalchemy] with_session and subquery loading

2016-06-28 Thread Michael Williamson


On Tuesday, June 28, 2016 at 2:57:08 PM UTC+1, Mike Bayer wrote:
>
>
>
> On 06/28/2016 05:28 AM, mic...@healx3.com  wrote: 
> > Hello! I sometimes find it more convenient to create to construct a 
> > query without a session, and then to add the session at the end using 
> > `with_session`. In particular, when constructing non-trivial queries, 
> > not having to pass the session around means one less argument to manage. 
> > However, this doesn't seem to work when using subquery loading, 
> > resulting in the error `AssertionError: Subquery session doesn't refer 
> > to that of our context. Are there broken context caching schemes being 
> > used?`. 
> > 
> > Is there a sensible way to get the subqueries to use the same session, 
> > or is the answer just to always construct queries with the session? 
>
>
> that assertion only applies to when the internal QueryContext is being 
> re-used, as is the case with baked query loading.  The QueryContext 
> itself created during the _compile_context() phase will contain 
> references to the Session within the subquery eager loaders.   As long 
> as you don't do anything with your original query other than call 
> with_session(), there's no error I can reproduce, e.g.: 
>
> from sqlalchemy import * 
> from sqlalchemy.orm import * 
> from sqlalchemy.ext.declarative import declarative_base 
>
> Base = declarative_base() 
>
>
> class A(Base): 
>  __tablename__ = 'a' 
>  id = Column(Integer, primary_key=True) 
>  bs = relationship("B") 
>
> class B(Base): 
>  __tablename__ = 'b' 
>  id = Column(Integer, primary_key=True) 
>  a_id = Column(ForeignKey('a.id')) 
>
> e = create_engine("sqlite://", echo=True) 
> Base.metadata.create_all(e) 
>
> s = Session(e) 
> s.add_all([A(bs=[B(), B()]), A(bs=[B(), B()])]) 
> s.commit() 
>
> q1 = Session().query(A).options(subqueryload(A.bs)) 
>
> for sess in [Session(e), Session(e), Session(e)]: 
>  for a in q1.with_session(sess): 
>  print a, a.bs 
>
>
>
> Please work up an example showing how you're getting that result, thanks! 
>
>
Thanks for the quick reply, and apologies for not providing an example in 
the first place. I think I worked out the issue: we've wrapped up the 
session:

class TransactionalSession(object):
def __init__(self, session):
self._session = session

def __enter__(self):
return self

def __exit__(self, exception_type, exception, traceback):
if exception is None:
self._session.commit()
else:
self._session.rollback()
self._session.close()

def __getattr__(self, key):
return getattr(self._session, key)

so when we try running the queries with subquery loading (for instance, as 
in your example, but with `TransactionalSession(Session(e))`), the session 
on `subq` is the underlying session, while the session on `context` is our 
own wrapped session. So, presumably the saner way of doing this would be 
either to use the underlying session directly, or to subclass `Session`?

 

>
>
> > 
> > Thanks 
> > 
> > Michael 
> > 
> > -- 
> > 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 sqlalchemy+...@googlegroups.com  
> > . 
> > To post to this group, send email to sqlal...@googlegroups.com 
>  
> > . 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] table not defined in SQLAlchemy

2016-06-28 Thread Mike Bayer



On 06/28/2016 06:50 AM, 'Moritz Liebelt' via sqlalchemy wrote:

Hi,
I will read all informations out of my table building.
In my opinion the connection is successfull but it cannot find the table!

My code:

|
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy import select
import cx_Oracle
engine =
create_engine('postgresql://postgres:postgres@localhost:5432/3DCityDB_kreis_boeblingen',
echo = True)
metadata = MetaData(bind=engine)
conn = engine.connect()

s = select([building.c.id])

result = conn.execute(s)
for row in result:
 print(row)
|

Can anyone please help me?

*error-message: NameError: name 'building' is not defined!*


In Python, every name we refer to has to come from somewhere, either 
from an import, an assignment (e.g. x = y), or a def or class 
definition.   In this case we are looking to use assignment.  You're 
looking to use a Table object here, so we need to make one.   We also 
want to make sure it has column objects that match up what's in our 
database, so we will use a feature called reflection.


Add this line right below your "MetaData" line and this will work:

building = Table('building', metadata, autoload_with=engine)

now you can work with "building.c.id".




*
*
But it is one tablename out of my database...

--
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 sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] with_session and subquery loading

2016-06-28 Thread Mike Bayer



On 06/28/2016 05:28 AM, mich...@healx3.com wrote:

Hello! I sometimes find it more convenient to create to construct a
query without a session, and then to add the session at the end using
`with_session`. In particular, when constructing non-trivial queries,
not having to pass the session around means one less argument to manage.
However, this doesn't seem to work when using subquery loading,
resulting in the error `AssertionError: Subquery session doesn't refer
to that of our context. Are there broken context caching schemes being
used?`.

Is there a sensible way to get the subqueries to use the same session,
or is the answer just to always construct queries with the session?



that assertion only applies to when the internal QueryContext is being 
re-used, as is the case with baked query loading.  The QueryContext 
itself created during the _compile_context() phase will contain 
references to the Session within the subquery eager loaders.   As long 
as you don't do anything with your original query other than call 
with_session(), there's no error I can reproduce, e.g.:


from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
bs = relationship("B")

class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(ForeignKey('a.id'))

e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

s = Session(e)
s.add_all([A(bs=[B(), B()]), A(bs=[B(), B()])])
s.commit()

q1 = Session().query(A).options(subqueryload(A.bs))

for sess in [Session(e), Session(e), Session(e)]:
for a in q1.with_session(sess):
print a, a.bs



Please work up an example showing how you're getting that result, thanks!






Thanks

Michael

--
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 sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Martijn van Oosterhout
On 27 June 2016 at 16:22, Mike Bayer  wrote:

> Not really sure, that URL itself won't allow a psycopg2 connection to even
> occur.


Yeah, I noticed that. psql has sensible defaults here that psycopg2
apparently doesn't have. In this case I'd just stripped the credentials out
of the script, sorry.



> The error means that the construct is trying to be generated as a string,
> like in a print statement.   But 1.1 has a new feature that allows default
> stringification of pg.ARRAY and other constructs to actually work.
>
> Need a stack trace at the very least.
>
>
Good point. Attached. Just to get some more information I put stopped a
debugger at the raise statement and got the following:

>
/home/martijn/virtualenv/eggs/SQLAlchemy-1.1.0b1-py2.7-linux-x86_64.egg/sqlalchemy/ext/compiler.py(459)__call__()
-> raise exc.CompileError(
(Pdb) l
454 if not fn:
455 try:
456 fn = self.specs['default']
457 except KeyError:
458 import pdb; pdb.set_trace()
459  -> raise exc.CompileError(
460 "%s construct has no default "
461 "compilation handler." % type(element))
462 return fn(element, compiler, **kw)
[EOF]
(Pdb) p locals()
{'self': ,
 'element': ARRAY(String()),
 'kw': {'type_expression': Column('reference', ARRAY(String()),
table=, primary_key=True, nullable=False,
server_default=DefaultClause('{}', for_update=False))},
 'pdb': ,
 'fn': None,
 'compiler': }
(Pdb) p self.specs
{'sqlite': }
(Pdb) p self.specs['default']
*** KeyError: KeyError('default',)

That sqlite reference looks a bit weird, did I miss some initialisation
somewhere?

Hope this helps,
-- 
Martijn van Oosterhout  http://svana.org/kleptog/

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


c
Description: Binary data


[sqlalchemy] table not defined in SQLAlchemy

2016-06-28 Thread 'Moritz Liebelt' via sqlalchemy
Hi,
I will read all informations out of my table building.
In my opinion the connection is successfull but it cannot find the table!

My code:

import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy import select
import cx_Oracle
engine = 
create_engine('postgresql://postgres:postgres@localhost:5432/3DCityDB_kreis_boeblingen',
 
echo = True)
metadata = MetaData(bind=engine)
conn = engine.connect()

s = select([building.c.id])

result = conn.execute(s)
for row in result:
 print(row)

Can anyone please help me?

*error-message: NameError: name 'building' is not defined!*

But it is one tablename out of my database...

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] with_session and subquery loading

2016-06-28 Thread michael
Hello! I sometimes find it more convenient to create to construct a query 
without a session, and then to add the session at the end using 
`with_session`. In particular, when constructing non-trivial queries, not 
having to pass the session around means one less argument to manage. 
However, this doesn't seem to work when using subquery loading, resulting 
in the error `AssertionError: Subquery session doesn't refer to that of our 
context. Are there broken context caching schemes being used?`.

Is there a sensible way to get the subqueries to use the same session, or 
is the answer just to always construct queries with the session?

Thanks

Michael

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.