[sqlalchemy] mutable extension problems sa-0.7.9

2012-12-04 Thread Dmitry Bogun
I have tried to create some custom SA type. And got in situation when I can't find correct wayout. Minimal test case in attach. My app have class SiteVersion, it can be used as regular object and as SA mmaped object. When I use only SiteVesionDeco(see attach) all works fine, except propagating

Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2012-12-04 Thread Piotr Deszyński
Hello, Is there a way to use ZopeTransactionExtension using ShardedSession? I just cannot figure it out. When I use it then I'm getting exception during any query: unbound method after_begin() must be called with ZopeTransactionExtension instance as first argument (got SessionMaker instance

Re: [sqlalchemy] Bug Report: A regression in the MSSQL Dialect in 0.8.x

2012-12-04 Thread Michael Bayer
On Dec 3, 2012, at 10:20 PM, Derek Harland wrote: The MSSQL dialect in 0.8.x seems to have had many of the reflection methods changed from something like: @reflection.cache def get_view_names(self, connection, schema=None, **kw): to @reflection.cache

Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2012-12-04 Thread Michael Bayer
test cases and stack traces would be a start On Dec 4, 2012, at 9:29 AM, Piotr Deszyński wrote: Hello, Is there a way to use ZopeTransactionExtension using ShardedSession? I just cannot figure it out. When I use it then I'm getting exception during any query: unbound method

Re: [sqlalchemy] mutable extension problems sa-0.7.9

2012-12-04 Thread Michael Bayer
this is an incorrect __eq__() method: def __eq__(self, other): if not isinstance(other, SiteVersion): raise NotImplementedError('Expect %s instance, got %s' % (SiteVersion, other)) suppose I have a custom object Foo: class Foo(object): def __eq__(self, other):

Re: [sqlalchemy] mutable extension problems sa-0.7.9

2012-12-04 Thread Dmitry Bogun
Sorry, my fault. I was not enough attentive while read this http://docs.python.org/2.7/reference/datamodel.html?highlight=__eq__#object.__eq__ part of documentation. I somehow thought that comparison method must wait NotImplementedError in case of impassible comparison. But now, when you

[sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
We can turn on 'PRAGMA foreign_key = on' when running sqlite3 database system manually. However it is not a convenient way. So I wonder when I run the migration script using sqlalchemy and alembic tool, targeting sqlite3, is there a way to enforce the foreign key constraint in the migration

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread Audrius Kažukauskas
On Tue, 2012-12-04 at 08:53:43 -0800, junepeach wrote: We can turn on 'PRAGMA foreign_key = on' when running sqlite3 database system manually. However it is not a convenient way. So I wonder when I run the migration script using sqlalchemy and alembic tool, targeting sqlite3, is there a way

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
Thanks Audrius. Do you have a simple working example in sqlalchemy? I am not familiar with sqlalchemy. My migration script will separate from other python development codes. So it is better to put 'PRAGMA foreign_keys=ON' in a configuration file. I am pretty new to all of those stuff. --

[sqlalchemy] Can't find any foreign key relationships between ...

2012-12-04 Thread Diego Woitasen
Hi, I have the following tables: rcpt_group_asoc = Table(mailing_rcptgroup_rcpts, Base.metadata, Column('rcpt_id', Integer, ForeignKey('mailing_rcpt.id')), Column('rcptgroup_id', Integer, ForeignKey('mailing_rcptgroup.id'))) class Rcpt(Base): __tablename__

[sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
After upgrading to SQLAlchemy 0.7.9 I know receive an error FlushError: Over 100 subsequent flushes have occurred within session.commit() - is an after_flush() hook creating new objects? which is was introduced by

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread Audrius Kažukauskas
On Tue, 2012-12-04 at 10:13:22 -0800, junepeach wrote: Thanks Audrius. Do you have a simple working example in sqlalchemy? I am not familiar with sqlalchemy. My migration script will separate from other python development codes. So it is better to put 'PRAGMA foreign_keys=ON' in a

Re: [sqlalchemy] Can't find any foreign key relationships between ...

2012-12-04 Thread Michael Bayer
On Dec 4, 2012, at 2:30 PM, Diego Woitasen wrote: Hi, I have the following tables: rcpt_group_asoc = Table(mailing_rcptgroup_rcpts, Base.metadata, Column('rcpt_id', Integer, ForeignKey('mailing_rcpt.id')), Column('rcptgroup_id', Integer,

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Michael Bayer
On Dec 4, 2012, at 3:04 PM, Jason wrote: After upgrading to SQLAlchemy 0.7.9 I know receive an error FlushError: Over 100 subsequent flushes have occurred within session.commit() - is an after_flush() hook creating new objects? which is was introduced by

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
Does this mean there is a limit to the number of queries I can run in a transaction? For example I am looping about 20 times. For each loop I insert one or two rows and do at least one query. There might be some more implicit queries when accessing relationship properties. If I set

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
Disregard that, I spoke too soon. There is something going on after it starts the commit process. On Tuesday, December 4, 2012 3:35:40 PM UTC-5, Jason wrote: Does this mean there is a limit to the number of queries I can run in a transaction? For example I am looping about 20 times. For

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
Ok I figured out the cause, but not the solution. I am using a mutable type for hstore columns. I have a UserDefinedType for Hstore that just passes everything through to psycopg2's hstore type: class HStore(UserDefinedType): SQLAlchemy type that passes through values to be handled by a

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
I have tried this with no luck. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/WIhv75pJw3gJ. To post to this group, send email to sqlalchemy@googlegroups.com.

Re: [sqlalchemy] Can't find any foreign key relationships between ...

2012-12-04 Thread Diego Woitasen
On Tuesday, December 4, 2012 5:12:51 PM UTC-3, Michael Bayer wrote: On Dec 4, 2012, at 2:30 PM, Diego Woitasen wrote: Hi, I have the following tables: rcpt_group_asoc = Table(mailing_rcptgroup_rcpts, Base.metadata, Column('rcpt_id', Integer,

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
On Tuesday, December 4, 2012 4:15:03 PM UTC-5, Jason wrote: Ok I figured out the cause, but not the solution. I am using a mutable type for hstore columns. I have a UserDefinedType for Hstore that just passes everything through to psycopg2's hstore type: class HStore(UserDefinedType):

Re: [sqlalchemy] Using Guid as Primary Key

2012-12-04 Thread Wolfgang Keller
Can I use the Guid as primary key? I am newbie to sql and mysql management. Using such auto-generated surrogate keys is always a really bad idea and the straightest and shortest way to data inconsistency hell (especially through duplicates). you've seen two guids generate as

Re: [sqlalchemy] Can't find any foreign key relationships between ...

2012-12-04 Thread Michael Bayer
On Dec 4, 2012, at 4:32 PM, Diego Woitasen wrote: I'm mixing ORM and Core in my app because I performance in critical in some parts of the code. Are there other problems related to this mix? I wouldn't call them problems, but to the degree that you're using plain Core

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Michael Bayer
have you tried 0.8 which now provides HSTORE built in ? it's not apparent from this code fragment why your flush process is producing residual state. I'd need a fully runnable and succinct test case to analyze exactly what's going on. On Dec 4, 2012, at 4:38 PM, Jason wrote: On

Re: [sqlalchemy] Using Guid as Primary Key

2012-12-04 Thread Michael Bayer
On Dec 4, 2012, at 4:46 PM, Wolfgang Keller wrote: Can I use the Guid as primary key? I am newbie to sql and mysql management. Using such auto-generated surrogate keys is always a really bad idea and the straightest and shortest way to data inconsistency hell (especially through

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread Michael Bayer
the FK constraint event is described here: http://docs.sqlalchemy.org/en/rel_0_8/dialects/sqlite.html#foreign-key-support this code can go whereever it is you build your engine, in env.py, or elsewhere. If the above isn't working, check the prerequisites mentioned, especially version of

Re: [sqlalchemy] Bug Report: A regression in the MSSQL Dialect in 0.8.x

2012-12-04 Thread Derek Harland
On 5/12/2012, at 4:30 AM, Michael Bayer wrote: On Dec 3, 2012, at 10:20 PM, Derek Harland wrote: The MSSQL dialect in 0.8.x seems to have had many of the reflection methods changed from something like: @reflection.cache def get_view_names(self, connection, schema=None, **kw):

Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2012-12-04 Thread Piotr Deszyński
If it's necessary I will provide both, the question before that is: Should ZopeTransactionExtension work with ShardedSession? Because if it wasn't designed for that, then there's no need to write test cases. Best regards W dniu wtorek, 4 grudnia 2012 16:31:16 UTC+1 użytkownik Michael Bayer