Re: [sqlalchemy] PG copy_expert, and sessions

2010-06-20 Thread Michael Bayer
first consult PG documentation to confirm that the copy expert function is transactional. Then all you need to do is run it with session execute: session.execute(COPY ...) session.commit() subtransactions=True is not relevant here. The usage of an external Transaction object is also not

Re: [sqlalchemy] is it possible to limit a session.query() to return only certain columns - not orm objects ?

2010-06-20 Thread Michael Bayer
you want to look at: 1. query.values(Class.foo, Class.bar) as well as 2. Session.query(Class.foo, Class.bar).all() #2 is in the ORM tutorial, and both are in the full Query API documentation. On Jun 19, 2010, at 3:37 PM, Jonathan Vanasco wrote: i know this is usually done with the select()

[sqlalchemy] UsageRecipes/UniqueObject without using declarative?

2010-06-20 Thread Nikolaj
Hi there, I'm trying to use the UniqueObject recipe for my project which does not use declarative_base(). However, I'm having trouble getting this to work and run into this error: sqlalchemy.orm.exc.UnmappedInstanceError: Class '__main__.Widget' is mapped, but this instance lacks

Re: [sqlalchemy] UsageRecipes/UniqueObject without using declarative?

2010-06-20 Thread Michael Bayer
On Jun 20, 2010, at 7:54 AM, Nikolaj wrote: Hi there, I'm trying to use the UniqueObject recipe for my project which does not use declarative_base(). However, I'm having trouble getting this to work and run into this error: sqlalchemy.orm.exc.UnmappedInstanceError: Class

[sqlalchemy] modifying a field

2010-06-20 Thread Aref Nammari
I have the following code: db = SqlSoup('sqlite:///c:\\tutorial.db3') db_dynamic = 'tf_user' DB = db.entity(db_dynamic) print DB ColHeader = DB.c.keys() conn = db.connection() #modify a field DB.password = 'hello' db.flush() #get the table data data = select([db.tf_user],) listdata=[] for row in

Re: [sqlalchemy] Re: modifying a field

2010-06-20 Thread Michael Bayer
On Jun 20, 2010, at 5:33 PM, Aref wrote: I tried that and still cannot seem to change the field. is password an actual column in the database table ? create a SQLSoup using an engine obtained via create_engine(), and specify echo=True on that engine to see what SQL is actually emitted.

[sqlalchemy] Re: modifying a field

2010-06-20 Thread Aref
yes the field password is an actual column. Below is the table definition: from sqlalchemy import * from datetime import datetime metadata = MetaData('sqlite:///c:\\tutorial.db3') user_table = Table(\ 'tf_user', metadata, Column('id', Integer,

[sqlalchemy] Re: modifying a field

2010-06-20 Thread Aref
Here is the echoed info when the code is run: 2010-06-20 16:00:02,546 INFO sqlalchemy.engine.base.Engine.0x...6c50 PRAGMA table_info(tf_user) 2010-06-20 16:00:02,546 INFO sqlalchemy.engine.base.Engine.0x...6c50 () 2010-06-20 16:00:02,546 INFO sqlalchemy.engine.base.Engine.0x...6c50 PRAGMA

Re: [sqlalchemy] Re: modifying a field

2010-06-20 Thread Michael Bayer
On Jun 20, 2010, at 5:53 PM, Aref wrote: db = SqlSoup('sqlite:///c:\\tutorial.db3') db_dynamic = 'tf_user' DB = db.entity(db_dynamic) print DB ColHeader = DB.c.keys() conn = db.connection() #modify a field DB.password = 'hello' db.flush() It appears you're using a method called

[sqlalchemy] Re: is it possible to limit a session.query() to return only certain columns - not orm objects ?

2010-06-20 Thread Jonathan Vanasco
you want to look at: 1. query.values(Class.foo, Class.bar) ah, thank you very much. i was struggling with that earlier from the API -- i thought i only needed to do query.values( foo , bar ) but that didn't work. 2. Session.query(Class.foo, Class.bar).all() #2 is in the ORM tutorial,

Re: [sqlalchemy] Re: is it possible to limit a session.query() to return only certain columns - not orm objects ?

2010-06-20 Thread Michael Bayer
On Jun 20, 2010, at 9:08 PM, Jonathan Vanasco wrote: you want to look at: 1. query.values(Class.foo, Class.bar) ah, thank you very much. i was struggling with that earlier from the API -- i thought i only needed to do query.values( foo , bar ) but that didn't work. 2.