Re: [sqlalchemy] SQLite: How can I turn on ON DELETE CASCADE from within sqlalchemy?

2015-08-06 Thread Jinghui Niu
Hi Mike. Thanks for your reply. That's great news!

Just want to clarify on which level such constraints will be placed? 
sqlalchemy or the underlying database?

So now if I want to use passive delete, which relies solely on the 
underlying SQLite database's constraints not the sqlalchemy's, I just need 
to set the foreign key argument like this:
ForeignKey('items.record_id', ondelete='CASCADE'))
when I declare the classes. This will set the constraint on the underlying 
database. Is my understanding correct?


On Thursday, August 6, 2015 at 2:48:26 PM UTC-7, Michael Bayer wrote:



 On 8/6/15 5:31 PM, Jinghui Niu wrote:

 I know you can set this constraint if you are directly dealing with 
 sqlite3, but how can I achieve this database level setting from within 
 sqlalchemy? 

 The documentation reads:

 Note that these clauses are not supported on SQLite, and require InnoDB 
 tables when used with MySQL. They may also not be supported on other 
 databases.


 So is there a way to turn this feature on from within sqlalchemy? Thanks. 

 that documentation is probably out of date.  The ON DELETE CASCADE 
 directive will emit on SQLite like on any other backend.   You would need 
 to enable foreign key support on a per-connection basis for sqlite3 in 
 order for them to take effect: 


 http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#foreign-key-support




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


[sqlalchemy] SQLite: How can I turn on ON DELETE CASCADE from within sqlalchemy?

2015-08-06 Thread Jinghui Niu
I know you can set this constraint if you are directly dealing with 
sqlite3, but how can I achieve this database level setting from within 
sqlalchemy?

The documentation reads:

 Note that these clauses are not supported on SQLite, and require InnoDB 
 tables when used with MySQL. They may also not be supported on other 
 databases.


So is there a way to turn this feature on from within sqlalchemy? Thanks. 

-- 
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/d/optout.


Re: [sqlalchemy] Where can I find the signature definition for @validates functions?

2015-08-06 Thread Mike Bayer



On 8/6/15 6:04 PM, Jinghui Niu wrote:

I read the documentation and encountered this:
|
@validates('addresses', include_backrefs=False)
def validate_address(self, key, address):
assert '@' in address.email
return address
|


What are the key and address in the validate_address function? I can't 
find any explanation in our documentation. Do they have any meaning or 
expect any special objects? Can I use other names for those two 
parameters here? Thanks.


assuming you are reading 
http://docs.sqlalchemy.org/en/rel_1_0/orm/mapped_attributes.html?highlight=validates#simple-validators, 
that *is* the documentationaddress is the value that's being 
validated and key is the name of the attribute being altered, in this 
case addresses.  the parameters are positional.




--
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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: mysql datetime column containing the value 0000-00-00 00:00:00 is retrieved incorrectly as None

2015-08-06 Thread vitaly numenta
I understand that -00-00 00:00:00 would be an invalid datetime, but 
there is presently no way in sqlalchemy to distinguish between actual Null 
and the -00-00 00:00:00 value that mysql substitutes when it gets an 
invalid datetime

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy-alembic group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Where can I find the signature definition for @validates functions?

2015-08-06 Thread Jinghui Niu
I read the documentation and encountered this:
@validates('addresses', include_backrefs=False) 
def validate_address(self, key, address): 
assert '@' in address.email 
return address


What are the key and address in the validate_address function? I can't find 
any explanation in our documentation. Do they have any meaning or expect 
any special objects? Can I use other names for those two parameters here? 
Thanks.

-- 
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/d/optout.


Re: [sqlalchemy] SQLite: How can I turn on ON DELETE CASCADE from within sqlalchemy?

2015-08-06 Thread Mike Bayer



On 8/6/15 5:56 PM, Jinghui Niu wrote:

Hi Mike. Thanks for your reply. That's great news!

Just want to clarify on which level such constraints will be placed? 
sqlalchemy or the underlying database?


So now if I want to use passive delete, which relies solely on the 
underlying SQLite database's constraints not the sqlalchemy's, I just 
need to set the foreign key argument like this:

|
ForeignKey('items.record_id',ondelete='CASCADE'))
|
when I declare the classes. This will set the constraint on the 
underlying database. Is my understanding correct?


yes the ondelete key at that level is for the DDL emitted to the 
database when you emit metadata.create_all(), assuming the table is not 
there yet.








On Thursday, August 6, 2015 at 2:48:26 PM UTC-7, Michael Bayer wrote:



On 8/6/15 5:31 PM, Jinghui Niu wrote:

I know you can set this constraint if you are directly dealing
with sqlite3, but how can I achieve this database level setting
from within sqlalchemy?

The documentation reads:

Note that these clauses are not supported on SQLite, and
require InnoDB tables when used with MySQL. They may also not
be supported on other databases.


So is there a way to turn this feature on from within sqlalchemy?
Thanks.

that documentation is probably out of date.  The ON DELETE CASCADE
directive will emit on SQLite like on any other backend.   You
would need to enable foreign key support on a per-connection basis
for sqlite3 in order for them to take effect:


http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#foreign-key-support

http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#foreign-key-support




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

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


mysql datetime column containing the value 0000-00-00 00:00:00 is retrieved incorrectly as None

2015-08-06 Thread vitaly numenta
platform = mac os x yosemtite
sqlalchemy version = '0.9.4'
mysql version = 5.6.23

table definition:
CREATE TABLE `twitter_tweets` (
  `uid` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `retweet` tinyint(1) NOT NULL,
  `lang` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `text` mediumtext COLLATE utf8_unicode_ci,
  `retweeted_userid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `username` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `userid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `real_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `retweeted_status_id` varchar(40) COLLATE utf8_unicode_ci DEFAULT '',
  `retweet_count` int(11) DEFAULT '-2',
  `retweeted_username` varchar(100) COLLATE utf8_unicode_ci DEFAULT '',
  `retweeted_real_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT '',
  `in_reply_to_status_id` varchar(40) COLLATE utf8_unicode_ci DEFAULT '',
  `in_reply_to_userid` varchar(100) COLLATE utf8_unicode_ci DEFAULT '',
  `in_reply_to_username` varchar(100) COLLATE utf8_unicode_ci DEFAULT '',
  `contributors` text COLLATE utf8_unicode_ci,
  `stored_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`uid`),
  KEY `created_at_idx` (`created_at`),
  KEY `stored_at_idx` (`stored_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Insert statement:
insert  into twitter_tweets (`uid`, `created_at`) values (3, '-00-00 
00:00:00') on duplicate key update uid=uid;

Query in sql alchemy returns None for the value:
e.execute('select created_at from taurus_collectors.twitter_tweets where 
created_at=-00-00 00:00:00').fetchall()
[(None,)]

For comparison, the same query in mysql shell (and Sequel Pro app) returns 
a non-Null value:

mysql select created_at from taurus_collectors.twitter_tweets where 
created_at=-00-00 00:00:00;

+-+

| created_at  |

+-+

| -00-00 00:00:00 |

+-+

1 row in set (0.00 sec)

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy-alembic group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] SQLite: How can I turn on ON DELETE CASCADE from within sqlalchemy?

2015-08-06 Thread Mike Bayer



On 8/6/15 5:31 PM, Jinghui Niu wrote:
I know you can set this constraint if you are directly dealing with 
sqlite3, but how can I achieve this database level setting from within 
sqlalchemy?


The documentation reads:

Note that these clauses are not supported on SQLite, and require
InnoDB tables when used with MySQL. They may also not be supported
on other databases.


So is there a way to turn this feature on from within sqlalchemy? Thanks.
that documentation is probably out of date.  The ON DELETE CASCADE 
directive will emit on SQLite like on any other backend.   You would 
need to enable foreign key support on a per-connection basis for sqlite3 
in order for them to take effect:


http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#foreign-key-support





--
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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] loops and session

2015-08-06 Thread Richard Gerd Kuesters

thanks Mike!

ok, going further then:

1. i'm using postgres (isolation_level=REPEATABLE READ);
2. it's inside a twisted app, into a defer, _but_ the session lifecycle 
starts and ends in that defer;
3. in that same (python) process, there's a txpostgres connection 
ongoing (in another twisted defer anywhere).


can some of that cause any interference that can cause this behaviour?




On 08/06/2015 03:29 PM, Mike Bayer wrote:



On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:

well, i ran today into an issue i never seen before.

considering this simple example:

session = get_session()
objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session


this will print True only in the first iteration. basically, the 
other objects are not bound to a session anymore. is there any reason 
for this, or am i doing something wrong?


cant reproduce:

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

Base = declarative_base()


class NewObject(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)

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

session = Session(e)

objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session

output:

sql stuff...
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True







best regards,
richard.
--
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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
attachment: richard.vcf

[sqlalchemy] loops and session

2015-08-06 Thread Richard Gerd Kuesters

well, i ran today into an issue i never seen before.

considering this simple example:

   session = get_session()
   objs = []

   for ign in xrange(10):
o = NewObject()
objs.append(o)

   session.add_all(objs)
   session.commit()

   for obj in objs:
print obj in session


this will print True only in the first iteration. basically, the other 
objects are not bound to a session anymore. is there any reason for 
this, or am i doing something wrong?


best regards,
richard.

--
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/d/optout.
attachment: richard.vcf

Re: [sqlalchemy] loops and session

2015-08-06 Thread Mike Bayer



On 8/6/15 3:03 PM, Richard Gerd Kuesters wrote:

thanks Mike!

ok, going further then:

1. i'm using postgres (isolation_level=REPEATABLE READ);
2. it's inside a twisted app, into a defer, _but_ the session 
lifecycle starts and ends in that defer;
3. in that same (python) process, there's a txpostgres connection 
ongoing (in another twisted defer anywhere).


can some of that cause any interference that can cause this behaviour?


inside of a twisted defer and this is not inside a threadpool? 
absolutely.  that's entirely chaotic and anything goes.ironic 
considering the simple and safe promises of explicit async code !










On 08/06/2015 03:29 PM, Mike Bayer wrote:



On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:

well, i ran today into an issue i never seen before.

considering this simple example:

session = get_session()
objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session


this will print True only in the first iteration. basically, the 
other objects are not bound to a session anymore. is there any 
reason for this, or am i doing something wrong?


cant reproduce:

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

Base = declarative_base()


class NewObject(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)

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

session = Session(e)

objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session

output:

sql stuff...
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True







best regards,
richard.
--
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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] loops and session

2015-08-06 Thread Mike Bayer



On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:

well, i ran today into an issue i never seen before.

considering this simple example:

session = get_session()
objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session


this will print True only in the first iteration. basically, the other 
objects are not bound to a session anymore. is there any reason for 
this, or am i doing something wrong?


cant reproduce:

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

Base = declarative_base()


class NewObject(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)

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

session = Session(e)

objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session

output:

sql stuff...
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True







best regards,
richard.
--
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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] loops and session

2015-08-06 Thread Richard Gerd Kuesters
well, the whole function itself is not async (where the session gets 
created and closed), neither the psycopg2 connection, but inside this 
chaos, providing the function to run into it's own thread seems to work 
now ... go figure.


thanks! :)


On 08/06/2015 04:19 PM, Mike Bayer wrote:



On 8/6/15 3:03 PM, Richard Gerd Kuesters wrote:

thanks Mike!

ok, going further then:

1. i'm using postgres (isolation_level=REPEATABLE READ);
2. it's inside a twisted app, into a defer, _but_ the session 
lifecycle starts and ends in that defer;
3. in that same (python) process, there's a txpostgres connection 
ongoing (in another twisted defer anywhere).


can some of that cause any interference that can cause this behaviour?


inside of a twisted defer and this is not inside a threadpool? 
absolutely.  that's entirely chaotic and anything goes.ironic 
considering the simple and safe promises of explicit async code !










On 08/06/2015 03:29 PM, Mike Bayer wrote:



On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:

well, i ran today into an issue i never seen before.

considering this simple example:

session = get_session()
objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session


this will print True only in the first iteration. basically, the 
other objects are not bound to a session anymore. is there any 
reason for this, or am i doing something wrong?


cant reproduce:

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

Base = declarative_base()


class NewObject(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)

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

session = Session(e)

objs = []

for ign in xrange(10):
o = NewObject()
objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
print obj in session

output:

sql stuff...
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True







best regards,
richard.
--
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 
mailto: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/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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
attachment: richard.vcf

Re: [sqlalchemy] advice sought - handling a relationship cascade

2015-08-06 Thread Jonathan Vanasco

On Wednesday, August 5, 2015 at 10:08:35 PM UTC-4, Michael Bayer wrote:

 viewonly=True?


That was the EXACTLY what I needed.  Thank you! 

-- 
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/d/optout.