[sqlalchemy] Replacing a Session Engine

2008-11-24 Thread Koen Bok
Hey I was wondering if it was possible to replace an engine in a session. It does not seem to work, but maybe I'm doing something really stupid. http://pastie.org/322501 Kindest regards, Koen Bok - madebysofa.com --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: inserting

2008-11-24 Thread MikeCo
Oops, not quite right. str(table.c.colname) returns 'table.colname, and that doesn't work right as dictionary key. You need col only as dictionary key. http://pastebin.com/fd0653b0 has some tests Interesting question is does SA intend that table.colname work in the dictionary definition? --

[sqlalchemy] Re: Trouble with Strings getting converted to Unicode types

2008-11-24 Thread Michael Bayer
Harish Vishwanath wrote: Hello, Thanks for your input. I consulted PySqlite's docs : They have something like Connection.text_factory, which is by default set to Unicode. If it is set to str, that is., connection.text_factory = str, then it wont convert strings to Unicode. I glanced

[sqlalchemy] Re: inserting

2008-11-24 Thread Michael Bayer
the actual Column object or its key can be placed in the dict. MikeCo wrote: Oops, not quite right. str(table.c.colname) returns 'table.colname, and that doesn't work right as dictionary key. You need col only as dictionary key. http://pastebin.com/fd0653b0 has some tests Interesting

[sqlalchemy] Re: inserting

2008-11-24 Thread MikeCo
Using 0.5.0rc4 doesn't seem to do that. or what am I doing wrong? The test, http://pastebin.com/fd0653b0 , looks like when using the Column object, the values inserted are all None (test 1). When the key is the fully qualified table.column, the value inserted is always the default value for the

[sqlalchemy] Re: inserting

2008-11-24 Thread Michael Bayer
oh, right. Column objects only work when you say insert().values(**dict). MikeCo wrote: Using 0.5.0rc4 doesn't seem to do that. or what am I doing wrong? The test, http://pastebin.com/fd0653b0 , looks like when using the Column object, the values inserted are all None (test 1). When the

[sqlalchemy] Re: Replacing a Session Engine

2008-11-24 Thread Michael Bayer
that is the way to do it as far as switching engines. your example doesn't work because the state of p1 is persistent as opposed to pending, so the example updates a row that isn't there. you need to build a copy constructor on Person and make a new, non-persistent Person object for your

[sqlalchemy] Re: Replacing a Session Engine

2008-11-24 Thread Koen Bok
Ok, that sounds logical, but that defeats the purpose of it for me :-) Whenever a Checkout user logs out I clear the session. On a new login I create fresh session that has to re-cache lot of data. The logins depend on a valid postgres user. If I could find a way to replace the engine/connection

[sqlalchemy] Re: Replacing a Session Engine

2008-11-24 Thread az
cant u cache all these objects elsewhere then sess.merge() them? On Monday 24 November 2008 22:33:53 Koen Bok wrote: Ok, that sounds logical, but that defeats the purpose of it for me :-) Whenever a Checkout user logs out I clear the session. On a new login I create fresh session that has

[sqlalchemy] Re: Invalid SQL for not None on relation attributes

2008-11-24 Thread Yoann Roman
Not yet, I'm still recovering from the first one :-). On Nov 20, 10:50 pm, Michael Bayer [EMAIL PROTECTED] wrote: very nice - this fix is applied in r5314.  It's not every day someone   gives us a patch for strategies.py...have any more ? :) On Nov 20, 2008, at 9:47 PM, Yoann Roman wrote:

[sqlalchemy] Poolclass argument to create_engine

2008-11-24 Thread Iain
I was wondering if it would be possible to get the code changed to accept the poolclass argument to create_engine (and other functions?) optionally as a string reference to a Pool subclass rather than requiring the class itself. The reason I ask is because SQLAlchemy is often a component of a

[sqlalchemy] Questionable query times.

2008-11-24 Thread TheShadow
http://pastebin.ca/1266308 In the link above you will see some output and code. Some questions I have: 1) Why are these queries taking on a magnitude of 10 times slower than they should be? 2) Could it be the implementation I am using? If so what is recommended for using the system as you see

[sqlalchemy] Re: Questionable query times.

2008-11-24 Thread Michael Bayer
On Nov 24, 2008, at 8:50 PM, TheShadow wrote: http://pastebin.ca/1266308 In the link above you will see some output and code. Some questions I have: 1) Why are these queries taking on a magnitude of 10 times slower than they should be? 2) Could it be the implementation I am using? If

[sqlalchemy] Re: Trouble with Strings getting converted to Unicode types

2008-11-24 Thread Michael Bayer
On Nov 24, 2008, at 11:47 PM, Harish Vishwanath wrote: Hello, Thanks for your reply. Please see the below implementation : Implementation 1: def my_con_func(): ... print My Connection func ... import sqlite3.dbapi2 as sqlite ... con = sqlite.connect(:memory:) ...

[sqlalchemy] Re: Poolclass argument to create_engine

2008-11-24 Thread Michael Bayer
which frameworks are we talking about here ? since yes I think if a framework is going to take over the job of calling create_engine() then they should provide proper inputs. There's a lot of things which can be passed to create_engine() which don't work as strings. On Nov 24, 2008,

[sqlalchemy] Re: Questionable query times.

2008-11-24 Thread TheShadow
First I appreciate your responding. But I need more information as to why this is taking so long and this is because of the following: When I started looking for a DBAPI I started with the MySQLdb module executing queries against local host versus a remote host was faster but even against remote

[sqlalchemy] Re: Questionable query times.

2008-11-24 Thread Michael Bayer
On Nov 25, 2008, at 12:51 AM, TheShadow wrote: First I appreciate your responding. But I need more information as to why this is taking so long and this is because of the following: When I started looking for a DBAPI I started with the MySQLdb module executing queries against local host

[sqlalchemy] Re: Poolclass argument to create_engine

2008-11-24 Thread Iain
I was talking about TurboGears. I must admit I had assumed that these were considered details that most frameworks would prefer to hide away as TG does, but a quick look over at Pylons suggests they've implemented a somewhat more customizable way of initiating the engine but involves a bit more

[sqlalchemy] Selecting from a self-referential mapper: recursive joins?

2008-11-24 Thread Eric Ongerth
Below, I have attached a working testcase. It works, yes -- but my question is that I need to make an improved version of a particular method on one of my classes. The following model will probably explain itself for the most part. I'll let you read it first, then offer a few explanatory notes