[sqlalchemy] Adding ManyToMany relationships when creating an object

2009-11-20 Thread Lea H
Hi all, I wanted to ask if there is a way to add many to many relationships to the database every time a new object is inserted. I have a Question that has a many to many relationship to AnswerCode. Every time I create and insert a new Question I'd like to add the corresponding answer codes to

[sqlalchemy] stored procedures and bind params on mssql

2009-11-20 Thread Damian
Hello, Does anyone have much experience using sqlalchemy with stored procedures on mssql? I'm trying to use bind params with text() in a query and it doesn't seem to like them ie, i try running: s = sql.text(DECLARE @res INT; exec @res = LOGINS_ID :x ; select @res;) and then: Session.execute(s,

[sqlalchemy] get_or_create(**kwargs) ?

2009-11-20 Thread chaouche yacine
Hello, This is the first time I try an ORM, and I chose SQLAlchemy, which is popular amongst pythonistas. Since I am a complete beginner, here's my beginner's two cents question : Suppose you have a very basic model like this (pseudo code) : User(firstname,lastname,nick,ManyToOne(city))

Re: [sqlalchemy] Adding ManyToMany relationships when creating an object

2009-11-20 Thread Michael Bayer
Lea H wrote: Hi all, I wanted to ask if there is a way to add many to many relationships to the database every time a new object is inserted. I have a Question that has a many to many relationship to AnswerCode. Every time I create and insert a new Question I'd like to add the corresponding

Re: [sqlalchemy] get_or_create(**kwargs) ?

2009-11-20 Thread Michael Bayer
chaouche yacine wrote: But how can I be sure that the city of New Jersey will be inserted before the user in the database so that the new user row will get the proper city id ? SQLAlchemy takes care of that automatically once you configure the relationship between user and city using

Re: [sqlalchemy] get_or_create(**kwargs) ?

2009-11-20 Thread Conor
Michael Bayer wrote: chaouche yacine wrote: But how can I be sure that the city of New Jersey will be inserted before the user in the database so that the new user row will get the proper city id ? SQLAlchemy takes care of that automatically once you configure the relationship

[sqlalchemy] Automatically Creating Table Definitions

2009-11-20 Thread Rodney Haynie
In SQLAlchemy, is there some process available that will create the following code from an existing database/table? i.e. the database has one table, the name of the table is users. After running the process, the following code would be created in a file: users = Table('users', metadata,

Re: [sqlalchemy] Automatically Creating Table Definitions

2009-11-20 Thread Conor
Rodney Haynie wrote: In SQLAlchemy, is there some process available that will create the following code from an existing database/table? i.e. the database has one table, the name of the table is users. After running the process, the following code would be created in a file: users =

Re: [sqlalchemy] Automatically Creating Table Definitions

2009-11-20 Thread Rodney Haynie
Conor, Conor wrote: Rodney Haynie wrote: In SQLAlchemy, is there some process available that will create the following code from an existing database/table? i.e. the database has one table, the name of the table is users. After running the process, the following code would be created

[sqlalchemy] Weird error with update

2009-11-20 Thread Mariano Mara
... or, at least, is weird for me :) Hi everyone. I'm running a pylons controller with the following instruction: meta.Session.query(ESMagicNumber).filter( ESMagicNumber.uuid==request.params['uuid_']).\ update({'last_access':datetime.datetime.now()}) but I'm

Re: [sqlalchemy] Weird error with update

2009-11-20 Thread Mike Conley
On Fri, Nov 20, 2009 at 5:14 PM, Mariano Mara mariano.m...@gmail.comwrote: ... or, at least, is weird for me :) Hi everyone. I'm running a pylons controller with the following instruction: meta.Session.query(ESMagicNumber).filter(