[sqlalchemy] sqlalchemy.ext.declarative and scoped session

2008-03-29 Thread Bobby Impollonia
Hi. I recently switched a sqlalchemy project from using manual mapping of classes to ext.declarative. This is in a turbogears project and I am using their metadata and mapper. Before I had: from turbogears.database import metadata, mapper users_table = sqlalchemy.Table('users', metadata, ... )

[sqlalchemy] Re: sqlalchemy.ext.declarative and scoped session

2008-03-29 Thread Michael Bayer
On Mar 29, 2008, at 9:13 AM, Bobby Impollonia wrote: Hi. I recently switched a sqlalchemy project from using manual mapping of classes to ext.declarative. This is in a turbogears project and I am using their metadata and mapper. Before I had: from turbogears.database import metadata,

[sqlalchemy] Re: String to query (python) expression

2008-03-29 Thread Michael Bayer
On Mar 27, 2008, at 5:31 PM, maxi wrote: Hi, Is possible (Are there some built-in function?) to convert a string sql expresion to sqlalchemy expression? I will try to explain this with an example An user_table and User mapped class: sql_where = 'name like '%John%' sql_where -

[sqlalchemy] Re: SQL INNER JOIN Question

2008-03-29 Thread Michael Bayer
On Mar 27, 2008, at 2:36 PM, [EMAIL PROTECTED] wrote: SELECT dbo.computer.group_id AS computerid, dbo.computer.name AS computername, dbo.computer_group.group_id AS groupid, dbo.computer_group.name AS groupname FROM dbo.computer, dbo.computer_group Anyone who can offer a quick statement

[sqlalchemy] Re: sqlalchemy.ext.declarative and scoped session

2008-03-29 Thread Michael Bayer
On Mar 29, 2008, at 10:23 AM, Bobby Impollonia wrote: Awesome! I added that __mapper_args__ to each of my classes and it totally worked. All of my test cases (written before switching to declarative) pass now where they had all failed before (lots of code relying on .query), so I am happy

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-29 Thread Lukasz Szybalski
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 id(session) and len(list(session)). The session id is unique every

[sqlalchemy] using a model inherits from dict

2008-03-29 Thread Mike Bernson
I am trying to use models that inherit from dict. The models use attribute access for the sqlachemy attributes and dict style access for gui stuff. This allow me to do things like model[column_name].editable for gui to see if item should be grayed out and model.column_name for access the

[sqlalchemy] Re: using a model inherits from dict

2008-03-29 Thread Bobby Impollonia
If the only dict behavior you need is accessing elements with [], another approach is that you could implement __getitem__ in your model but not inherit from dict. On Sat, Mar 29, 2008 at 3:08 PM, Mike Bernson [EMAIL PROTECTED] wrote: I am trying to use models that inherit from dict. The

[sqlalchemy] Re: using a model inherits from dict

2008-03-29 Thread Mike Bernson
what I have looks to work. I just wanted to known if there where other things that might be problems later. Bobby Impollonia wrote: If the only dict behavior you need is accessing elements with [], another approach is that you could implement __getitem__ in your model but not inherit from

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-29 Thread Randall Smith
Paul Johnston wrote: Hi, eng = sqlalchemy.create_engine(mssql:///?dsn=mydsn,UID=myusername,PWD=mypass,module=pyodbc) Try this: eng = sqlalchemy.create_engine(mssql://myusername:mypass@/?dsn=mydsn,module=pyodbc) Paul You shouldn't need to define a dsn. This should work: