[sqlalchemy] Re: Full connection pool close

2009-02-02 Thread Smoke
On 29 Gen, 21:03, Rick Morrison rickmorri...@gmail.com wrote: I then added a wait option which simply sleeps for brief period after closing the SA connections, and then does the connection count check. With a 1/2 second delay between the closing of the SA connection pool and the check for

[sqlalchemy] Textual SQL

2009-02-02 Thread Pavel Skvazh
Session.execute('INSERT INTO SOMETHING SOMETHING / DELETE/ UPDATE') Do I have to call Session.commit() after this or it's already taken care of? In other words does the literal sql statements follow the session transaction rules or they act on there own? And since this works and worked for me

[sqlalchemy] Re: Textual SQL

2009-02-02 Thread Bob Farrell
On Mon, Feb 02, 2009 at 09:56:15AM -0800, Pavel Skvazh wrote: Session.execute('INSERT INTO SOMETHING SOMETHING / DELETE/ UPDATE') Do I have to call Session.commit() after this or it's already taken care of? In other words does the literal sql statements follow the session transaction

[sqlalchemy] Re: Textual SQL

2009-02-02 Thread MikeCo
Commit behavior depends on how you configure the session's autocommit property. Follow the log messages in this little test. from sqlalchemy import MetaData, Table, Column, String from sqlalchemy.orm import sessionmaker meta = MetaData('sqlite:///') Session = sessionmaker(bind=meta.bind) t =

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-02 Thread Gloria W
Thanks for taking the time to respond. I still get an error, please see below. I show the record, just after a successful insert. I then show the error on delete. When I go into the db and manually delete these records, they exist as expected, and the deletion is successful. Thank you in

[sqlalchemy] Re: Outer joins with ORM and single table polymorphism

2009-02-02 Thread Michael Bayer
outerjoin() will bridge between multiple tables if you specify a list to a single outerjoin() call (see the examples in the reference documentation). However for joined table inheritance with the ORM no explicit joining is necessary, see the documenation on using with_polymorphic in the

[sqlalchemy] Invalid bind parameter name in Oracle

2009-02-02 Thread phcornelus
Hello, I work with sqlalchemy 0.5.2, python 2.5 and Oracle 8.17. Consider the following code: ora = create_engine('oracle://user:passw...@server/INSTANCE', use_ansi=False, label_length=None) metadata = MetaData(bind=ora) part_list_table =

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-02 Thread Piotrek Byzia
'Homologues' seems to work, but no luck with 'Interactions' where I get rid of 'id' and code below returns error on join conditions: What should be ForeignKey and relation in each of this classes? Too bad that there is a declarative model introduced in the tutorial but all more advanced examples

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-02 Thread Piotrek Byzia
OK, it seems to work finally :) Thanks to this http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#configuring-relations On Feb 2, 2:03 pm, Piotrek Byzia piotr.by...@gmail.com wrote: 'Homologues' seems to work, but no luck with 'Interactions' where I get rid of 'id' and code

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-02-02 Thread Alessandro Dentella
On Sun, Feb 01, 2009 at 04:41:11PM -0500, Michael Bayer wrote: Here you go, its a psycopg2 bug. Familiarize yourself with the attached test case, then post it on the psycopg2 mailing list. Thanks a lot for you fast and valuable help, as usual. I verified that version 2.0.8 of psycopg2 does

[sqlalchemy] Re: [SA0.5.2/PG] KeyError: pg_expression_2

2009-02-02 Thread Michael Bayer
thanks for the test, this is fixed in r5772. On Feb 2, 2009, at 2:11 AM, Andreas Jung wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there, using SA 0.5.2/Postgres 7.4.22. Reflecting an existing database gives me this: (Pdb) c

[sqlalchemy] Re: Invalid bind parameter name in Oracle

2009-02-02 Thread Michael Bayer
this bug is fixed in SQLA 0.6, in that the oracle dialect knows how to quote bind parameters that contain illegal characters. its a non- trivial change since cx_oracle requires that the bind parameter dictionary itself also contain the quote characters. For 0.5, there's a few options.

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-02 Thread Michael Bayer
this operation is illegal: def DELETE(self,memberid,fields=None): memberProfile = MemberProfile(memberID=memberid) self.session.delete(memberProfile) you must load MemberProfile from the database or merge() the above object into the session. On Feb 2, 2009, at 4:11 PM, Gloria W

[sqlalchemy] Using count with distinct?

2009-02-02 Thread Stuart Axon
I've got a fairly simple query in postgres... any idea how I do this in sqlalchemy - I couldn't find any info about this select count(distinct device_id) from externalbuild join build on build.id = externalbuild.build_id where external_id = '1' and not is_known BTW,

[sqlalchemy] Re: Using count with distinct?

2009-02-02 Thread Michael Bayer
use this: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/expressions.html#sqlalchemy.sql.expression.distinct On Feb 2, 2009, at 7:53 PM, Stuart Axon wrote: I've got a fairly simple query in postgres... any idea how I do this in sqlalchemy - I couldn't find any info about this

[sqlalchemy] cpython jdbc

2009-02-02 Thread KMCB
I was wondering if anyone was aware of a JDBC DBAPI module for cpython. I have looked at PYJDBC and was interested in avoiding using that extra level of ICE. I was thinking maybe someone would have back ported zxJDBC from Jython. Or used that as a starting point, to create a module and had a C

[sqlalchemy] Re: Using count with distinct?

2009-02-02 Thread Stuart Axon
Cheers... Hm, still @ quite the n00b stage... got this far Build.join(ExternalBuild).distinct().count() But when I try Build.join(ExternalBuild, ExternalBuild.build_id == Build.id) It says: Traceback (most recent call last): File console, line 1, in module File string, line 1, in lambda

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-02 Thread rdmurray
Quoth jason kirtland j...@discorporate.us: Now, how do I get SQLAlchemy to pass that dictionary into the MySQLdb 'connect'? :) You can pass it in via the create_engine's connect_args: http://www.sqlalchemy.org/docs/05/dbengine.html#custom-dbapi-connect-arguments Thanks. I should have

[sqlalchemy] How to display table creation sql statement?

2009-02-02 Thread limodou
I want to know if there is a simple way to show the table creation sql statement, and I don't want to display them in debug mode. I just want to show sql statement via table definition. -- I like python! UliPad The Python Editor: http://code.google.com/p/ulipad/ UliWeb simple web framework:

[sqlalchemy] Re: Using count with distinct?

2009-02-02 Thread Michael Bayer
I'm not quite sure how you've arranged for query.join() to be on your mapped class, but the right side, onclause form of query.join() uses tuples. q.join((rgt, onclause), (rgt, onclause), ...) On Feb 2, 2009, at 8:40 PM, Stuart Axon wrote: Cheers... Hm, still @ quite the n00b

[sqlalchemy] Re: How to display table creation sql statement?

2009-02-02 Thread Michael Bayer
current method is http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring . 0.6 has something more general purpose. On Feb 2, 2009, at 8:55 PM, limodou wrote: I want to know if there is a simple way to show the table creation sql statement, and I don't

[sqlalchemy] Re: How to display table creation sql statement?

2009-02-02 Thread limodou
On Tue, Feb 3, 2009 at 11:40 AM, Michael Bayer mike...@zzzcomputing.com wrote: current method is http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring . 0.6 has something more general purpose. Thanks and I want to know if I must call