[sqlalchemy] Access for DB session in Celery

2012-05-30 Thread Tomek Banasiak
Hi, I'm using some DB operation inside my Celery tasks and i dont know which is good approach for accessing DB session in each task. Now i store in global celery config on start a DB session: scoped_session(sessionmaker(bind=engine)) And each task takes that class from config and makes an

[sqlalchemy] Using Oracle Indexes...

2012-05-30 Thread Christian Klinger
Hi, Hi i use sqlalchemy to map an existing oracle table to my class via the declarative syntax. One of the columns is indexed. Do i understand it correctly to only specify the index in my Column? class Example(...) mnr = Column(MNR, String(12), primary_key=True, index=True) And how can

[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-30 Thread Jeff
Unique constraints have worked well. Thanks! On May 29, 1:44 pm, Michael Bayer mike...@zzzcomputing.com wrote: yup On May 29, 2012, at 1:01 PM, Jeff wrote: Thanks  Michael, Just to make clear what exactly begin_nested() is contributing: Normal case: session.rollback() goes

[sqlalchemy] Another Parent instance is not bound to a Session; lazy load...

2012-05-30 Thread Maurizio Nagni
Hello all, my curious situation is the following. A very simplified version of the code is: for data in res: obj = MyObject() ---here I fill the obj, aventually doing some query (create session, get, close) to SA sess = createSession() sess.add(obj) sess.commit()

[sqlalchemy] mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski
Hello, I'm trying to autolaod my table image but it keeps complaining that the table doesn't exists. I've enabled the echo = true and I see that you specify in the query: SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE],

Re: [sqlalchemy] mssql and specifying a schema name?

2012-05-30 Thread Michael Bayer
the default schema name is determined by: SELECT default_schema_name FROM sys.database_principals WHERE name = (SELECT user_name()) AND type = 'S' for some reason on your system it's coming up as MyDatabase. You'd want to fix that so that it

Re: [sqlalchemy] Using Oracle Indexes...

2012-05-30 Thread Michael Bayer
On May 30, 2012, at 7:38 AM, Christian Klinger wrote: Hi, Hi i use sqlalchemy to map an existing oracle table to my class via the declarative syntax. One of the columns is indexed. Do i understand it correctly to only specify the index in my Column? class Example(...) mnr =

[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski
On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: the default schema name is determined by:             SELECT default_schema_name FROM             sys.database_principals             WHERE name = (SELECT user_name())             AND type = 'S' for some reason on your

[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski
On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: the default schema name is determined by:             SELECT default_schema_name FROM             sys.database_principals             WHERE name = (SELECT user_name())             AND type = 'S' for some reason on your

Re: [sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Michael Bayer
On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote: On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: the default schema name is determined by: SELECT default_schema_name FROM sys.database_principals WHERE name = (SELECT

[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski
On May 30, 2:35 pm, Michael Bayer mike...@zzzcomputing.com wrote: On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote: On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: the default schema name is determined by:             SELECT default_schema_name FROM      

Re: [sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Michael Bayer
On May 30, 2012, at 3:56 PM, Lukasz Szybalski wrote: On May 30, 2:35 pm, Michael Bayer mike...@zzzcomputing.com wrote: On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote: On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: the default schema name is

Re: [sqlalchemy] Another Parent instance is not bound to a Session; lazy load...

2012-05-30 Thread Michael Bayer
well yes, the way you're doing this is entirely the opposite of how the ORM is designed to function.The Session has been developed in order to work in an intelligent manner with full graphs of interrelated objects, all coordinated under the umbrella of a transaction which applies atomicity

Re: [sqlalchemy] Another Parent instance is not bound to a Session; lazy load...

2012-05-30 Thread Claudio Freire
On Wed, May 30, 2012 at 8:39 PM, Michael Bayer mike...@zzzcomputing.com wrote: well yes, the way you're doing this is entirely the opposite of how the ORM is designed to function.    The Session has been developed in order to work in an intelligent manner with full graphs of interrelated

[sqlalchemy] Can't make an association table use InnoDB

2012-05-30 Thread Jeff
Having difficulty creating a database that includes the following plumbing: class Base(object): id = Column(Integer, primary_key=True) __table_args__ = {'mysql_engine': 'InnoDB'} Base = declarative_base(cls=Base) class Event(Base): Avalanche_Event_Association =

Re: [sqlalchemy] Another Parent instance is not bound to a Session; lazy load...

2012-05-30 Thread Michael Bayer
On May 30, 2012, at 8:53 PM, Claudio Freire wrote: Thing is, in order to work with a large volume of objects, you're forced to do this, otherwise the session can grow uncontrollably. flush periodically, and don't maintain references to things you're done with. The Session does not

Re: [sqlalchemy] Can't make an association table use InnoDB

2012-05-30 Thread Michael Bayer
This might be because the tables you're trying to reference are themselves not InnoDB. Try running DESCRIBE on the referenced tables at the MySQL console to help confirm this, as well as the same CREATE TABLE statement below. On May 30, 2012, at 11:31 PM, Jeff wrote: Having difficulty