[sqlalchemy] Re: Connecting to MySQL

2008-07-11 Thread Heston James - Cold Beans
Column('created', DateTime, default=func.now()), Column('updated', DateTime, onupdate=func.now())) You can set both default= and onupdate= on the same Column if you want 'updated' to be non-NULL on insert. That sounds like a nice clean way of doing this Jason, I'm more than

[sqlalchemy] Re: Connecting to MySQL

2008-07-11 Thread Heston James - Cold Beans
Hello Rick, These mapper extensions look very good, I've used a similar concept in other ORM's in the past for all manner of things and have a couple of decent ways to utilize them in this current application. Cheers, Heston From: sqlalchemy@googlegroups.com [mailto:[EMAIL

[sqlalchemy] autoload=True and asdecimal=False

2008-07-11 Thread Eric Lemoine
Hello When using autoload the created Numeric columns have asdecimal set to True (I use postgres, dunno if it's different with other databases). If would like that they have asdecimal set to False. Can I force that without having to override the results of the autoload with explicit

[sqlalchemy] miruku 0.1a6 released.

2008-07-11 Thread Olli Wang
miruku is a migration toolkit for SQLAlchemy. I'm pleased to release miruku 0.1a6. There are several bugs fixed since 0.1a3. You may need to re-read the tutorial to adapt some not backward-compatible updates. If you have any suggestion or question, welcome to report at

[sqlalchemy] M2M relationship

2008-07-11 Thread Heston James - Cold Beans
Good morning all, So, this morning's challenge has been learning many-to-many relationships, after reading through the tutorial I understand most of the core concepts of how it should work but I'm struggling to actually make it do so, I thought I would come and rely on you good people to help

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
NameError's are thrown usualy by import'ing or similar mechanisms. have a look on your code. eventualy post the whole traceback? On Friday 11 July 2008 12:14:12 Heston James - Cold Beans wrote: Good morning all, So, this morning's challenge has been learning many-to-many relationships,

[sqlalchemy] Can't reconnect until invalid transaction is rolled back after application sits idle overnight.

2008-07-11 Thread Ryan Parrish
Using SQLAlchemy 0.4.4 I am having a problem with SQLAlchemy where after the application that uses SQLAlchemy has been sitting overnight and a user makes the first queries of the day thru the app that uses SA, SQLAlchemy throws an error saying 'MySQL server has gone away', which I understand the

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
NameError's are thrown usualy by import'ing or similar mechanisms. have a look on your code. eventualy post the whole traceback? Hello Mate, I think you're right, but the problem is that I don't know what I 'should' be importing into the class. See, I have two files; Post.py and

[sqlalchemy] Re: Can't reconnect until invalid transaction is rolled back after application sits idle overnight.

2008-07-11 Thread Michael Bayer
On Jul 11, 2008, at 9:23 AM, Ryan Parrish wrote: Using SQLAlchemy 0.4.4 I am having a problem with SQLAlchemy where after the application that uses SQLAlchemy has been sitting overnight and a user makes the first queries of the day thru the app that uses SA, SQLAlchemy throws an error

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Michael Bayer
On Jul 11, 2008, at 9:59 AM, Heston James - Cold Beans wrote: NameError's are thrown usualy by import'ing or similar mechanisms. have a look on your code. eventualy post the whole traceback? Hello Mate, I think you’re right, but the problem is that I don’t know what I ‘should’ be

[sqlalchemy] Re: sqlalchemy connection pooling and mysql last_insert_id()

2008-07-11 Thread Henk
As far as I know SqlAlchemy does not use LAST_INSERT_ID() (at least not for single row inserts), At the mysql protocol level, the id created for the auto inc column will be returned for each insert statement (as the result code for that command). The python MySQLdb dbapi driver will make this

[sqlalchemy] SA Performance (some profiling on simple selects)

2008-07-11 Thread Henk
Hi I did some profiling a simple select type query to check SA performance for such use-cases The test consiste of a very simple Order record: order = Table('tblorder', metadata, Column('order_id', Integer, primary_key = True), Column('order_user_id', Integer),

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
the association table is an instance of Table, and does not need its own class. It's easiest to declare the association table in the same module as that which it is used, in this case post.py. Ok this sounds fine, I've done this now, declaring the table in the post.py module. When you

[sqlalchemy] Re: Can't reconnect until invalid transaction is rolled back after application sits idle overnight.

2008-07-11 Thread Ryan Parrish
On Jul 11, 10:03 am, Michael Bayer [EMAIL PROTECTED] wrote:. The reason you're getting the disconnect exception in the first place   is because the pool_recycle feature only works upon checkout from the   pool.  So the solution is the same, ensure all connections are   returned to the pool

[sqlalchemy] Re: Can't reconnect until invalid transaction is rolled back after application sits idle overnight.

2008-07-11 Thread Michael Bayer
On Jul 11, 2008, at 10:45 AM, Ryan Parrish wrote: On Jul 11, 10:03 am, Michael Bayer [EMAIL PROTECTED] wrote:. The reason you're getting the disconnect exception in the first place is because the pool_recycle feature only works upon checkout from the pool. So the solution is the same,

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
if u look up the stacktrace/traceback, u'll see which statement in your own code triggered the error. is it in the mapping-part or is still in table-declaration part? do all 3 tables use same metadata? On Friday 11 July 2008 17:31:31 Heston James - Cold Beans wrote: the association table is

[sqlalchemy] Re: Connecting to MySQL

2008-07-11 Thread jason kirtland
Lukasz Szybalski wrote: On Thu, Jul 10, 2008 at 11:59 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: On Thu, Jul 10, 2008 at 11:26 AM, Heston James - Cold Beans [EMAIL PROTECTED] wrote: Session.add is a version 0.5 method, you're maybe running 0.4.6? In the 0.4.x

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
if u look up the stacktrace/traceback, u'll see which statement in your own code triggered the error. is it in the mapping-part or is still in table-declaration part? do all 3 tables use same metadata? Thank you for your comments so far, I appreciate you helping me out on this. The entire

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
i'm not very familiar with declarative but in any way i dont see where u bind a) the metadata to the engine, and b) the declarative-stuff to the metadata. maybe its something i'm missing but maybe read more on those. On Friday 11 July 2008 19:20:21 Heston James - Cold Beans wrote: if u look

[sqlalchemy] Re: mysql innodb table insert problem

2008-07-11 Thread lilo
If I do manual insert into sql server like INSERT INTO lookup (username, shardname) VALUES ('0', 'shard1');, all works fine. But sqlalchemy doesn't insert for whatever reason into innodb table. Here is my shard session: create_session_lookup = sessionmaker(class_=ShardedSession,

[sqlalchemy] Re: mysql innodb table insert problem

2008-07-11 Thread Rick Morrison
I have shard session set to transactional. Does this conflict with innodb transaction? No, but it means your inner sess.begin() and sess.commit() are now within the scope of an outer transaction, so your inner sess.commit() has no effect. Since you immediately issue a sess.clear() after

[sqlalchemy] Re: SA Performance (some profiling on simple selects)

2008-07-11 Thread az
about (ways of) query compilation: for example in dbcook i have query-filters expressed as plain python functions, and that adds 3 or 4 more levels additional to the usual query building. here the levels: expr.translating: -a: py-func - makeExpresion - expr -b: expr - walk( Translator(

[sqlalchemy] autoload primary key

2008-07-11 Thread Eric Lemoine
Hello Are there particular conditions for the autoload mechanism to discover the primary key. If I remove Line 12 of this code http://paste.turbogears.org/paste/3183, I get this traceback http://paste.turbogears.org/paste/3182. Thanks a lot, -- Eric

[sqlalchemy] Re: autoload primary key

2008-07-11 Thread Michael Bayer
ive never observed a scenario where SQLA could not reflect the primary key status of a column. Feel free to share wtih us what database youre using and the exact DDL used to generate the table in question. On Jul 11, 2008, at 4:07 PM, Eric Lemoine wrote: Hello Are there particular

[sqlalchemy] Re: autoload primary key

2008-07-11 Thread Eric Lemoine
On Fri, Jul 11, 2008 at 11:00 PM, Michael Bayer [EMAIL PROTECTED] wrote: ive never observed a scenario where SQLA could not reflect the primary key status of a column. Feel free to share wtih us what database youre using and the exact DDL used to generate the table in question. Well, the

[sqlalchemy] Re: mysql innodb table insert problem

2008-07-11 Thread lilo
Thanks, I got it to work now. But why did it work for myisam table in the first place. Shouldn't session scope problem also have affected the inserts for myisam table. Insert into myisam table worked because it does not support transactions? On Jul 11, 4:03 pm, Rick Morrison [EMAIL PROTECTED]