Are you doing any relationship assignments in the User constructor?
Because if the assigned object is in a session the User will also be put
in the same one automatically. Otherwise the default behaviour is
exactly what you expect. If you do a: print session.new, you should not
see anything in there. Also, you might want to read up on the object
states in the docs. A standard object is first in "detached state".
Cheers
Sebastian
On 07/22/2013 04:22 PM, Michel Albert wrote:
Hi,
I realised that SA adds an instance to the session as soon as I
instantiate it. How/Where can I disable this?
For example: currently I have this behaviour:
>>> session = get_session()
>>> my_user = User(email='f...@example.com')
>>> len(session.query(User))
1
but instead I would like to have the following:
>>> session = get_session()
>>> my_user = User(email='f...@example.com')
>>> len(session.query(User))
0
>>> session.add(my_user)
>>> len(session.query(User))
1
--
mich.
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.
--
check out www.pointcloud9.com
Sebastian Elsner - Pipeline Technical Director - RISE
t: +49 30 20180300 flor...@risefx.com
f: +49 30 61651074 www.risefx.com
RISE FX GmbH
Schlesische Strasse 28, Aufgang B, 10997 Berlin
c/o action concept, An der Hasenkaule 1-7, 50354 Hürth
Geschaeftsfuehrer: Sven Pannicke, Robert Pinnow
Handelsregister Berlin HRB 106667 B
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.