[sqlalchemy] Creating Custom SQL

2010-06-03 Thread Jan-Eric
Hi! I have a problem with constructing a custom SQL statement. I would like to create the following SQL DATA_SUB( somefixed-date, INTERVAL column-expression MONTHS) I tried the following approach: - sqlalchemy.func.DATE_SUB(startDate,sqlalchemy.literal_column(INTERVAL %s MONTHS %

[sqlalchemy] reflecting existing databases with no a priori knowledge of their structure

2010-06-03 Thread Harry Percival
Hi All, I'm building a tool to extract info from databases.  The user/programmer doesn't have any advance knowledge of the structure of the database before they load it, and i want to dynamically generate mapped classes for the database. i just want to check there isn't some helpful sqlalchemy

Re: [sqlalchemy] Creating Custom SQL

2010-06-03 Thread Michael Bayer
On Jun 3, 2010, at 5:06 AM, Jan-Eric wrote: Hi! I have a problem with constructing a custom SQL statement. I would like to create the following SQL DATA_SUB( somefixed-date, INTERVAL column-expression MONTHS) I tried the following approach: -

Re: [sqlalchemy] Am I really doing this right?

2010-06-03 Thread Michael Bayer
On Jun 2, 2010, at 5:02 PM, Nick Retallack wrote: I have a lot of questions, so bear with me. I've been having some doubts about whether I'm really using sqlalchemy in a good way. -- Is there any use case for having more than one session active in the same thread? yes, if you wanted

RE: [sqlalchemy] reflecting existing databases with no a priori knowledge of their structure

2010-06-03 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Harry Percival Sent: 03 June 2010 16:24 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] reflecting existing databases with no a priori knowledge of their structure Hi

Re: [sqlalchemy] reflecting existing databases with no a priori knowledge of their structure

2010-06-03 Thread Michael Bayer
On Jun 3, 2010, at 11:24 AM, Harry Percival wrote: Hi All, I'm building a tool to extract info from databases. The user/programmer doesn't have any advance knowledge of the structure of the database before they load it, and i want to dynamically generate mapped classes for the database.

Re: [sqlalchemy] Questions about session

2010-06-03 Thread Michael Bayer
On Jun 3, 2010, at 1:24 AM, Az wrote: +++ Questions +++ 1. Is this the correct way to use sessions or am I sort of abusing them? I dont see any poor patterns of use above. 2. When should I close a session? when you no longer need the usage of any of the objects associated with it, or

[sqlalchemy] SA on MySQL 3.23

2010-06-03 Thread King Simon-NFHD78
Hi, According to sqlalchemy/dialects/mysql/base.py, MySQL v3.23 should be supported in some form. However, with SA 0.6.1 and MySQL 3.23.58, I get the following error: import sqlalchemy as sa e = sa.create_engine('mysql://user:passw...@host') e.execute('select Hello World') Traceback (most

[sqlalchemy] Re: Questions about session

2010-06-03 Thread Az
Owning session has been closed? Can I still use deepcopy if the session has not been closed? How can I stop it from closing the sessions? The problem is that if I change my shallow copied dictionary, the objects are changed. Basically, I'm trying to do this state change thing where I'll take a

Re: [sqlalchemy] SA on MySQL 3.23

2010-06-03 Thread Michael Bayer
On Jun 3, 2010, at 1:15 PM, King Simon-NFHD78 wrote: Hi, According to sqlalchemy/dialects/mysql/base.py, MySQL v3.23 should be supported in some form. However, with SA 0.6.1 and MySQL 3.23.58, I get the following error: raise errorclass, errorvalue

Re: [sqlalchemy] Re: Questions about session

2010-06-03 Thread Michael Bayer
On Jun 3, 2010, at 1:58 PM, Az wrote: Owning session has been closed? Can I still use deepcopy if the session has not been closed? deepcopy has issues because SQLAlchemy places extra information on your objects, i.e. an _sa_instance_state attribute, that you dont want in your copy. You

[sqlalchemy] Re: Questions about session

2010-06-03 Thread Az
I think I get what you mean. In the mean time, another error popped up: Traceback (most recent call last): File Main.py, line 32, in module MCS.addToTable() File XXX/MonteCarloSimulation.py, line 138, in addToTable ### --- This function is described in the first post

[sqlalchemy] Re: Am I really doing this right?

2010-06-03 Thread Nick Retallack
On Jun 3, 8:53 am, Michael Bayer mike...@zzzcomputing.com wrote: Is it a common practice to pass the current session into the constructor of an ORM model?   no.   The session consumes your objects, not the other way around.  An object can always get its current session via

[sqlalchemy] Re: Am I really doing this right?

2010-06-03 Thread Nick Retallack
Pretend I bound that metadata and session to an engine at some point... On Jun 3, 12:59 pm, Nick Retallack nickretall...@gmail.com wrote: On Jun 3, 8:53 am, Michael Bayer mike...@zzzcomputing.com wrote: Is it a common practice to pass the current session into the constructor of an ORM