[sqlalchemy] Possible bug with subqueryload

2011-09-27 Thread King Simon-NFHD78
Hi, I think there may be a bug in the interaction between 'subqueryload' and having a default 'order_by' defined on a mapped class. When the subquery is run, it looks like the ORDER BY is being placed on the outer query, whereas it should be on the inner query. The full test case is below, but

[sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Chris Withers
Hi All, Say I have a class such as: class MyObj(Base) __tablename__='mytable' __table_args__=dict(autoload=True) ...but the Base's metadata isn't bound, and won't be until the app has started (ie: the model has been imported) as the connection string comes from the environment. Is

[sqlalchemy] what pool to use when using pgbouncer?

2011-09-27 Thread Chris Withers
Hi, I'm wondering what the recommended incantation of create_engine is in SA 0.7.3 if: - you're using pg_bouncer, and so essentially don't want a pool - you have a DSN, eg: 'host=xx dname=xx user=xx password=xx', rather than a SA url cheers, Chris -- Simplistix - Content Management,

Re: [sqlalchemy] Possible bug with subqueryload

2011-09-27 Thread Michael Bayer
Hi Simon - yeah that looks pretty buglike to me, mapper.order_by is not a frequently used feature so this one may need some adjustment. I've created http://www.sqlalchemy.org/trac/ticket/2287 to take a look at this and so far I'm targeting it at 0.6.9/0.7.3. On Sep 27, 2011, at 7:29 AM, King

Re: [sqlalchemy] Incorrect SQL generated for INSERT into PostgreSQL

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 1:12 AM, Nathan Robertson wrote: On Mon, Sep 26, 2011 at 11:05 PM, Michael Bayer wrote: On Sep 26, 2011, at 2:50 AM, Nathan Robertson wrote: Column('custid', Integer, Sequence('test.customer_custid_seq'), primary_key=True), for the Sequence, as with all schema

Re: [sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 10:50 AM, Chris Withers wrote: Hi All, Say I have a class such as: class MyObj(Base) __tablename__='mytable' __table_args__=dict(autoload=True) ...but the Base's metadata isn't bound, and won't be until the app has started (ie: the model has been

[sqlalchemy] Synchronizing data, want to track what has changed. Advice please.

2011-09-27 Thread Brian
hello all, I'm grabbing data from a Student Information System (SIS) about students and then saving that data in a local database. I then query my local database to create/modify/disable accounts in Active Directory and Google Apps. What I've been doing so far is the following: Set all

Re: [sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Chris Withers
On 27/09/2011 16:58, Michael Bayer wrote: ah, hm. interesting ! basically, not rea..^H^H^H OK actually this is very easy, using a technique I used previously to create abstract concrete mappers. This should probably be how we recommend people use reflection with mappings since this

Re: [sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 12:49 PM, Chris Withers wrote: On 27/09/2011 16:58, Michael Bayer wrote: ah, hm. interesting ! basically, not rea..^H^H^H OK actually this is very easy, using a technique I used previously to create abstract concrete mappers. This should probably be how we

RE: [sqlalchemy] Possible bug with subqueryload

2011-09-27 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Michael Bayer Sent: 27 September 2011 16:24 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Possible bug with subqueryload Hi Simon - yeah that looks pretty buglike

Re: [sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Chris Withers
On 27/09/2011 18:10, Michael Bayer wrote: That looks like it should ship with SA itself... Does it? on the website, sure :) Many of these things are better as recipes Meh, that used to be true of mixins. I'm very glad that's now in the core. The trouble with keeping this as a recipe is

Re: [sqlalchemy] what pool to use when using pgbouncer?

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 10:55 AM, Chris Withers wrote: Hi, I'm wondering what the recommended incantation of create_engine is in SA 0.7.3 if: - you're using pg_bouncer, and so essentially don't want a pool for that you use NullPool - you have a DSN, eg: 'host=xx dname=xx user=xx

Re: [sqlalchemy] delcarative with autoload when you have no connection

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 1:21 PM, Chris Withers wrote: On 27/09/2011 18:10, Michael Bayer wrote: That looks like it should ship with SA itself... Does it? on the website, sure :) Many of these things are better as recipes Meh, that used to be true of mixins. I'm very glad that's now

[sqlalchemy] Validation of new objects before committing

2011-09-27 Thread Kirk Strauser
Does SA natively support (or is there a module on PyPI that supports) client-side validation of SQLAlchemy objects? For example, I have this declarative class: class ImportedPayment(Base): __tablename__ = 'importedpayment' __table_args = {'schema': 'public'}

Re: [sqlalchemy] Possible bug with subqueryload

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 1:16 PM, King Simon-NFHD78 wrote: Great, thanks a lot :-) I only discovered it in a toy application, and the workaround (including order_by on the query) is not a problem. In this toy application, I was also wondering if there existed a mechanism for doing some sort

Re: [sqlalchemy] Synchronizing data, want to track what has changed. Advice please.

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 11:42 AM, Brian wrote: hello all, I'm grabbing data from a Student Information System (SIS) about students and then saving that data in a local database. I then query my local database to create/modify/disable accounts in Active Directory and Google Apps. What

Re: [sqlalchemy] Validation of new objects before committing

2011-09-27 Thread Michael Bayer
On Sep 27, 2011, at 1:57 PM, Kirk Strauser wrote: Does SA natively support (or is there a module on PyPI that supports) client-side validation of SQLAlchemy objects? For example, I have this declarative class: class ImportedPayment(Base): __tablename__ = 'importedpayment'

Re: [sqlalchemy] deferrable constraints

2011-09-27 Thread Wichert Akkerman
I hate to do this kind of thing, but I haven't gotten any feedback on this and I would love to hear some feedback/opinions. How do other people handle deferrable constraints? On 2011-9-14 13:59, Wichert Akkerman wrote: On 09/14/2011 12:25 PM, Wichert Akkerman wrote: Constraints marked as

Re: [sqlalchemy] deferrable constraints

2011-09-27 Thread Michael Bayer
the issue is, the deferrable flag on FK generates the keyword on SQLite during DDL and is not accepted by SQLite ? seems like we'd just get the SQLite dialect to not render that keyword (i.e. should be core behavior). Also as a workaround you could possibly use a @compiles(sqlite) on

Re: [sqlalchemy] Synchronizing data, want to track what has changed. Advice please.

2011-09-27 Thread Brian
I'm not sure how I could do that because I'd want to set active to 0 only on the students that are no longer going to school here. Maybe merge isn't the right thing to do, or maybe I need to rethink my algorithm. The bottom line is I need to know what records get added to the local database

Re: [sqlalchemy] Synchronizing data, want to track what has changed. Advice please.

2011-09-27 Thread Michael Bayer
SQLA itself can only give you what's changed in memory. so if you had an X(), and you set X.y to bar where it used to be foo, before a flush you can see that happen with session.dirty and attributes.get_history(x, y). I don't entirely understand the actual task here but if it has to do with

Re: [sqlalchemy] Synchronizing data, want to track what has changed. Advice please.

2011-09-27 Thread Brian
Thanks for your responses. I've been doing quite a bit of probing and I think I have what I need now to get the job done. Sorry for the confusion, I wasn't being very clear. The problem with setting active to 0 after the fact stems from the fact that I'm only querying each database for the