[sqlalchemy] Re: Efficient dictificationof result sets

2008-12-19 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Andreas Jung Sent: 19 December 2008 06:30 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: Efficient dictificationof result sets On 19.12.2008 2:57 Uhr, Michael Bayer

[sqlalchemy] Re: Efficient dictificationof result sets

2008-12-19 Thread az
exactly, the declarative layer is syntax sugar, i.e. shorter way to say same thing, same as elixir and dbcook - they just differ in how many things each one automates/hides. after that, i.e. after mappers compiled, it's all plain SA - sessions, queries etc... i dont know about elixir, although

[sqlalchemy] Re: Abstract base class

2008-12-19 Thread FrankB
Hi, I have a similar task, so I tried to use your proposal, but it didn't work for me: === from sqlalchemy import types as satypes from sqlalchemy import schema as saschema from sqlalchemy.engine import create_engine from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta from

[sqlalchemy] Re: Abstract base class

2008-12-19 Thread Michael Bayer
oops, do it like this: class BaseType(DeclarativeMeta): def __init__(newcls, classname, bases, dict_): dict_['notes'] = saschema.Column(satypes.String) DeclarativeMeta.__init__(newcls, classname, bases, dict_) clearly we'll have to figure out a more user friendly pattern

[sqlalchemy] Re: Abstract base class

2008-12-19 Thread az
On Friday 19 December 2008 16:58:12 Michael Bayer wrote: oops, do it like this: class BaseType(DeclarativeMeta): def __init__(newcls, classname, bases, dict_): dict_['notes'] = saschema.Column(satypes.String) DeclarativeMeta.__init__(newcls, classname, bases, dict_)

[sqlalchemy] order_by and group_by won't work as I want.

2008-12-19 Thread 有末 清華
Hi. Well, I want to output the HTML code from database. And the HTML code should be order by 'cost' and group_by 'category' The database table is like below. --- ID CategoryNameCost 0 foodbanana $1 1

[sqlalchemy] Re: order_by and group_by won't work as I want.

2008-12-19 Thread az
On Friday 19 December 2008 19:53:03 有末 清華 wrote: Hi. Well, I want to output the HTML code from database. And the HTML code should be order by 'cost' and group_by 'category' The database table is like below. --- ID CategoryName

[sqlalchemy] Decouple association proxy?

2008-12-19 Thread Arn Vollebregt
Hi, I am wondering if there is a way to completely decouple the association proxy declaration from my Python classes, and contain this to a database class? My goal is not to 'burden' developers looking at the main part of my code with SQLAlchemy when there is no need to directly interact with

[sqlalchemy] Re: Decouple association proxy?

2008-12-19 Thread az
class MyObject(object): myObjects = association_proxy('myPropertyProxy', 'myProperty', creator=createAssociationObject) u mean, this one line there is 'burden' ? put all that in separate function in another file, and just import and call it... how about all the other table, mapper, etc

[sqlalchemy] creating and dropping foreign key constraints using ORM

2008-12-19 Thread Faheem Mitha
Hi, I'm writing code (see below) to drop and add back foreign key constraints to a db table. Incidentally, this code is not working (the function just hangs) so I may have made some kind of syntax error. Anyway, I was wondering if there was some way to accomplish this in a more high-level

[sqlalchemy] Re: Decouple association proxy?

2008-12-19 Thread Michael Bayer
On Dec 19, 2008, at 2:11 PM, Arn Vollebregt wrote: Hi, I am wondering if there is a way to completely decouple the association proxy declaration from my Python classes, and contain this to a database class? My goal is not to 'burden' developers looking at the main part of my code with

[sqlalchemy] Re: Decouple association proxy?

2008-12-19 Thread arn vollebregt
From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer On Dec 19, 2008, at 2:11 PM, Arn Vollebregt wrote: I am wondering if there is a way to completely decouple the association proxy declaration from my Python classes, and contain this to a

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-19 Thread Ken
I've created a full test case that should reproduce the error for you. You'll need to create a database called 'test' on your local machine. I think I've isolated the problem to the use of the creator keyword argument, which I use in my application for various reasons.

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-19 Thread Michael Bayer
def setup(**kwargs): connection = MySQLdb.connections.Connection(**kwargs) engine = create_engine('mysql://', creator=lambda: connection, pool_recycle=2) the creator argument is a callable that returns a new connection when the pool needs one. Above, you are pre-connecting a

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-19 Thread Ken
Oh, I see. I was unaware that lambda evaluated the result only once, not each use. Thanks so much for your help. On Dec 19, 4:36 pm, Michael Bayer mike...@zzzcomputing.com wrote: def setup(**kwargs):      connection = MySQLdb.connections.Connection(**kwargs)      engine =

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-19 Thread Michael Bayer
oh, whoops, shouldnt be a lambda there: def setup(**kwargs): def connect(): return MySQLdb.connections.Connection(**kwargs) engine = create_engine('mysql://', creator=connect, pool_recycle=2) On Dec 19, 2008, at 6:56 PM, Ken wrote: Oh, I see. I was unaware that

[sqlalchemy] Re: creating and dropping foreign key constraints using ORM

2008-12-19 Thread Faheem Mitha
On Fri, 19 Dec 2008 15:10:07 -0500, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 19, 2008, at 2:43 PM, Faheem Mitha wrote: I'm writing code (see below) to drop and add back foreign key constraints to a db table. Incidentally, this code is not working (the function just hangs) so I

[sqlalchemy] Fwd: declarative_base and UNIQUE Constraint

2008-12-19 Thread FrankB
Hi, just for anyone arriving here to save some time: I tried this with 0.5rc4 and the following piece of code === from sqlalchemy import types as satypes from sqlalchemy import schema as saschema from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class