[sqlalchemy] deferral pattern idea

2008-03-31 Thread Jonathan LaCour
I've had a few situations recently when I've been optimizing some queries that I have been making through the ORM (via Elixir), and I've wanted to take advantage of deferred columns. However, I've found that defining which columns get deferred is often more appropriate to do at *query* time, not

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Sat, Mar 29, 2008 at 10:50 PM, Randall Smith [EMAIL PROTECTED] wrote: Paul Johnston wrote: Hi, eng = sqlalchemy.create_engine(mssql:///?dsn=mydsn,UID=myusername,PWD=mypass,module=pyodbc) Try this: eng =

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Rick Morrison
So what you are saying here is that sqlalchemy will figure out what driver to use? pyodbc or other? Sort of. Attempts are made to import appropriate modules until one doesn't fail. The order is: [pyodbc, mssql, adodbapi] I have tried this with svn version and I get traceback snipped: I've

[sqlalchemy] Querying for the existence of an object in the database

2008-03-31 Thread pyplexed
The continuing adventures of a newbie SA user... Could anyone tell me if there is a simple way of setting up a query which takes an object as an argument and checks for the existence of an object in the database? I know I can construct a query hard coding attributes to filter on, but I'm sure

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 9:53 AM, Rick Morrison [EMAIL PROTECTED] wrote: So what you are saying here is that sqlalchemy will figure out what driver to use? pyodbc or other? Sort of. Attempts are made to import appropriate modules until one doesn't fail. The order is: [pyodbc, mssql,

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Randall Smith
Lukasz Szybalski wrote: On Mon, Mar 31, 2008 at 9:53 AM, Rick Morrison [EMAIL PROTECTED] wrote: So what you are saying here is that sqlalchemy will figure out what driver to use? pyodbc or other? Sort of. Attempts are made to import appropriate modules until one doesn't fail. The order is:

[sqlalchemy] Re: Querying for the existence of an object in the database

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 12:02 PM, pyplexed wrote: The continuing adventures of a newbie SA user... Could anyone tell me if there is a simple way of setting up a query which takes an object as an argument and checks for the existence of an object in the database? by primary key ? assuming

[sqlalchemy] Re: Session/transaction questions

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 12:40 AM, Nicholas Riley wrote: Hi, I just tried out SQLAlchemy 0.4.4 on a simple project - the front end for a vending machine. It uses two MySQL database connections. I've used the session/transaction facilities so I can use SQLAlchemy's two- phase commit to

[sqlalchemy] Re: deferral pattern idea

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 9:41 AM, Jonathan LaCour wrote: I've had a few situations recently when I've been optimizing some queries that I have been making through the ORM (via Elixir), and I've wanted to take advantage of deferred columns. However, I've found that defining which columns get

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 12:21 PM, Rick Morrison [EMAIL PROTECTED] wrote: It looks to me as if you have unixodbc installed, but don't have a SQL Server driver installed, or it's named differently. Unixodbc drivers are here: http://www.unixodbc.org/drivers.html I'm not really up on my

[sqlalchemy] Re: deferral pattern idea

2008-03-31 Thread Jonathan LaCour
Michael Bayer wrote: I'll give you the private way to do it if you'd like to play with it Cool. This will be helpful to play with for now... since the query already can do this, it seems harmless enough to create a load_only() MapperOption. However, it seems in a way to be fundamentally

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Rick Morrison
You didn't say how am I supposed to use it in create engine? http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_options Anyway. I went into sqlalchemy/databases/mssql.py changed the line 791 to:self.drivername = params.get('driver', 'TDS') but I still get the: OK,

[sqlalchemy] Many-To-One Adjacency Relation: reference set on wrong side

2008-03-31 Thread Nebur
I've first time tried so set up a Many To One relation in one table. After flushing, the foreign key reference is set on the wrong side, and I failed to tell the mapper what I want. The example has a Man table where each son has a reference to its father: ++ class

[sqlalchemy] Re: Session/transaction questions

2008-03-31 Thread Nicholas Riley
On Mar 31, 1:34 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 31, 2008, at 12:40 AM, Nicholas Riley wrote: You shouldn't be doing anything with the SessionTransaction   explicitly, this is a backwards compatibility thing from 0.3.  Use   only begin()/commit() on the Session itself.  When

[sqlalchemy] Re: Session/transaction questions

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 3:54 PM, Nicholas Riley wrote: I tried setting the isolation level explicitly, but it didn't help: In [29]: self.session.close() In [30]: self.db._acm.execute('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED') In [31]: self.db._sucrose.execute('SET SESSION

[sqlalchemy] Re: Many-To-One Adjacency Relation: reference set on wrong side

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 3:33 PM, Nebur wrote: I've first time tried so set up a Many To One relation in one table. After flushing, the foreign key reference is set on the wrong side, and I failed to tell the mapper what I want. The example has a Man table where each son has a reference to its

[sqlalchemy] 0.3.9 to 0.4.4 ... instance already persistent when calling save()

2008-03-31 Thread johnnyice
I've been using http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons to help with the migration because the migration tutorial on SQLAlchemy (http://www.sqlalchemy.org/docs/04/ intro.html#overview_migration) only included a partial list of things that I would need to change

[sqlalchemy] Re: 0.3.9 to 0.4.4 ... instance already persistent when calling save()

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 4:18 PM, johnnyice wrote: I've been using http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons to help with the migration because the migration tutorial on SQLAlchemy (http://www.sqlalchemy.org/docs/04/ intro.html#overview_migration) only included

[sqlalchemy] Re: Session/transaction questions

2008-03-31 Thread Nicholas Riley
On Mar 31, 3:07 pm, Michael Bayer [EMAIL PROTECTED] wrote: The other thing you're probably hitting here is that the Session is   going to cache everything it loads until you clear out its data   (session.clear()) , or expire the data that it has loaded   (session.expire_all()).  This is why

[sqlalchemy] Re: Many-To-One Adjacency Relation: reference set on wrong side

2008-03-31 Thread Nebur
Thank you for pointing me to the problem (that fast !!) This was wrong indeed. It is clearified now, and working well. Ruben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group,

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 2:07 PM, Rick Morrison [EMAIL PROTECTED] wrote: You didn't say how am I supposed to use it in create engine? http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_options Anyway. I went into sqlalchemy/databases/mssql.py changed the line 791 to:

[sqlalchemy] Re: 0.3.9 to 0.4.4 ... instance already persistent when calling save()

2008-03-31 Thread johnnyice
What do you recommend instead of scopedsession? On Mar 31, 1:22 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 31, 2008, at 4:18 PM, johnnyice wrote: I've been usinghttp://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons to help with the migration because the

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Rick Morrison
I think I remember a Port= in the ODBC connection string. ...would you please try this format on line 816: connectors.append('Server=%s;Port=%d' % (keys.get('host'), keys.get ('port'))) ...I'll try it on Windows here. Rick --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Rick Morrison
...I'll try it on Windows here. Update: it seems to work fine on Windows. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 3:50 PM, Rick Morrison [EMAIL PROTECTED] wrote: I think I remember a Port= in the ODBC connection string. ...would you please try this format on line 816: connectors.append('Server=%s;Port=%d' % (keys.get('host'), keys.get('port'))) You are correct: Port= fixes it.

[sqlalchemy] Re: 0.3.9 to 0.4.4 ... instance already persistent when calling save()

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 4:49 PM, johnnyice wrote: What do you recommend instead of scopedsession? definitely use ScopedSession to manage your Sessions on a thread-local basis.Im talking about a specific feature of SS called ScopedSession.mapper, described here:

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-31 Thread john spurling
On Mar 29, 8:11 am, Lukasz Szybalski [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 10:54 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get

[sqlalchemy] Delayed foreign key resolving

2008-03-31 Thread askel
Hello everybody, I'm wondering if there is a standard way of doing something like the following: masters = Table('masters', meta, Column('id', Integer, primary_key=True), Column('name', String, unique, nullable=False) ) details = Table('details', meta, Column('id', Integer,

[sqlalchemy] Re: Delayed foreign key resolving

2008-03-31 Thread Michael Bayer
On Mar 31, 2008, at 11:37 PM, askel wrote: Hello everybody, I'm wondering if there is a standard way of doing something like the following: masters = Table('masters', meta, Column('id', Integer, primary_key=True), Column('name', String, unique, nullable=False) ) details =