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

2012-05-31 Thread Maurizio Nagni
First of all thanks to all of you for your answers and time. Michael let me say that I agree 100% with all you wrote and my will/wish is to work as you wrote, but when you are inside the ORM its easy, other is if you want to interact with the ORM from outside. In my actual system I have more

[sqlalchemy] Transplanting _order_by_clause when wrapping into subquery

2012-05-31 Thread Gunnlaugur Briem
Hi, When wrapping a query with an enclosing query to add columns computed from the original query's columns, I'm blatantly doing this: order_clause_list = ClauseList(*fact_query._order_by_clause) fact_query._order_by_clause = ClauseList() subq =

[sqlalchemy] Joinedload and polymorphic problem

2012-05-31 Thread mailing - effem
Hello everyone, I have a big problem that alone can not solve. There are tens of days I try to figure out how to solve this problem. I created a little test to make you understand better. http://pastebin.com/RGXmJWVj I need to know the value of d.CODE with a single query on ClassA. Is there

[sqlalchemy] Joinedload and polymorphic problem

2012-05-31 Thread Francesco
Hello everyone, I have a big problem that alone can not solve. There are tens of days I try to figure out how to solve this problem. I created a little test to make you understand better. http://pastebin.com/hdqR5P6G I need to know the value of d.CODE with a single query on ClassA. I need get a

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

2012-05-31 Thread Michael Schlenker
Am 30.05.2012 20:03, schrieb 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] Another Parent instance is not bound to a Session; lazy load...

2012-05-31 Thread Michael Bayer
Seems like you have a monumental problem to overcome. I'm glad you mentioned EJB and have a Java background. In EJB, at least back when I used the very early version 1.0, the concept of the transactional nature of various service methods is defined separate from the implementation of the

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

2012-05-31 Thread Claudio Freire
On Thu, May 31, 2012 at 12:50 AM, Michael Bayer mike...@zzzcomputing.com 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.  

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

2012-05-31 Thread Michael Bayer
On May 31, 2012, at 10:35 AM, Claudio Freire wrote: On Thu, May 31, 2012 at 12:50 AM, Michael Bayer mike...@zzzcomputing.com 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

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

2012-05-31 Thread Jeff
The tables don't exist yet. The Base.metadata.create_all(engine) is to create them. Thanks! On May 30, 11:52 pm, Michael Bayer mike...@zzzcomputing.com wrote: This might be because the tables you're trying to reference are themselves not InnoDB.  Try running DESCRIBE on the referenced tables

[sqlalchemy] Oracle Function Out Params

2012-05-31 Thread Justin Valentini
I'm having difficulty determining how to correctly call an oracle package function which returns a numeric value. I want to call this: BEGIN :out := my_schema.my_package.test_function(); END; I tried calling that using sqlalchemy.text() but I don't understand how to tell the procedure I want

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

2012-05-31 Thread Jeff
Perhaps it's relevant (though I suspect not) that the class Avalanche actually contains: class Avalanche(Base): events = relationship(Event, secondary=Avalanche_Event_Association) This is what prevents us from writing the classes in the following order in the database definition .py

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

2012-05-31 Thread Michael Bayer
create_all() only can determine the order of tables if you use ForeignKey and ForeignKeyConstraint objects correctly on the source Table objects and/or declarative classes. See http://docs.sqlalchemy.org/en/rel_0_7/orm/relationships.html#many-to-many and

Re: [sqlalchemy] Oracle Function Out Params

2012-05-31 Thread Michael Bayer
There's an outparam() construct specifically for Oracle OUT parameters. Here's an example: from sqlalchemy import text, bindparam, outparam result = \ db.execute(text('begin foo(:x_in, :x_out, :y_out, ' ':z_out); end;',

Re: [sqlalchemy] Joinedload and polymorphic problem

2012-05-31 Thread Michael Bayer
Joining to ClassA.b does not include an automatic upgrade of ClassB to also load it's joined inheritance table ClassC.This is actually something SQLAlchemy can't quite do yet unless you hardwired a with_polymorphic onto your ClassB, which means it would join to ClassC all the time. 0.8

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

2012-05-31 Thread Jeff
Thanks! I don't quite follow the statement about fully mapped association table being unusual. The first Many-to-Many example you linked was the structure I copied when making my own tables here. Have I deviated from it in some way? Or should the example on the site have viewonly=True, if being

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

2012-05-31 Thread Michael Bayer
On May 31, 2012, at 3:49 PM, Jeff wrote: Thanks! I don't quite follow the statement about fully mapped association table being unusual. your name Avalanche_Event_Association with CamelCase made me think it was mapped class, but this is not the case as you have it as a Table. the problem

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

2012-05-31 Thread Jeff
Well, one of the worst things that can happen in programming has happened: It now works, and I don't know why _ I didn't change anything that I know of, and I definitely didn't change the capitalization. Guess I'll just slowly back away from the machine and hope everything stays that way. Thanks

[sqlalchemy] Calling stored procedures in SQLAlchemy

2012-05-31 Thread Will Orr
Hello all! I'm having this *exact* bug from a few years ago wrt. calling stored procedures. https://groups.google.com/forum/?fromgroups#!topic/sqlalchemy/qA_ypVgJ1B0 What makes it worse, however, is that adding the autocommit execution option or explicitly starting and stopping a transaction

Re: [sqlalchemy] Calling stored procedures in SQLAlchemy

2012-05-31 Thread Michael Bayer
did you call Session.commit() ? otherwise you're still in an open transaction, assuming default settings. Session.execute() is not the same as engine.execute(), where the latter is autocommitting (assuming you also called execution_options(autocommit=True) for this particular text()