[sqlalchemy] Re: Somewhat complex union_all() question

2009-08-26 Thread Mike Conley
or should be a little better q=q1.union_all(q2,q3) -- Mike Conley On Thu, Aug 27, 2009 at 12:14 AM, Mike Conley wrote: > Did you try something like this? > > q1=session.query(P1.userid, P1.extra, P1.title, P1.body) > q2=session.query(P2.userid, "'X'", P2.title, P2.body) > q3=session.query(P

[sqlalchemy] Re: Somewhat complex union_all() question

2009-08-26 Thread Mike Conley
Did you try something like this? q1=session.query(P1.userid, P1.extra, P1.title, P1.body) q2=session.query(P2.userid, "'X'", P2.title, P2.body) q3=session.query(P3.userid, "'X'", P3.title, P3.body) q=q1.union_all(q2).union_all(q3) -- Mike Conley On Wed, Aug 26, 2009 at 10:45 PM, Seth wrote

[sqlalchemy] Somewhat complex union_all() question

2009-08-26 Thread Seth
I have three different types of post tables with all of the same columns except that the first table has an extra column named "type" (placed in-between the 'user_id' and 'title' columns of the other tables). I want to do a UNION ALL that will combine the data from all these tables into a single l

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-26 Thread chris e
The issue I'm having with the length is that I have a verification layer written in a mapper extension that verifies the length of what the user is inserting based on the field length. Guess I'll have to convert to bytes to determine the actual length of the data to be inserted. On Aug 26, 6:01 p

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-26 Thread Michael Bayer
On Aug 26, 2009, at 8:53 PM, chris e wrote: > > I just checked the trunk, it the same reflection code is in place, as > far as the column length is concerned. > > To me the question is, should sqlalchemy be aware of Char vs Byte > storage? > > Is VARCHAR2(400) the same as VARCHAR2(100 CHAR), by

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-26 Thread chris e
I just checked the trunk, it the same reflection code is in place, as far as the column length is concerned. To me the question is, should sqlalchemy be aware of Char vs Byte storage? Is VARCHAR2(400) the same as VARCHAR2(100 CHAR), by storage size it is, but do we want storage size or number of

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-26 Thread Michael Bayer
On Aug 26, 2009, at 6:56 PM, chris e wrote: > > I noticed that with reflection, my column lengths seems to be > incorrect for varchar2, and char columns that are using char storage > instead of byte storage. > > I.E. a VARCHAR2(400 CHAR) colum, is reported to have a length of 1600 > by sqlalchem

[sqlalchemy] potential oracle character column reflection bug?

2009-08-26 Thread chris e
I noticed that with reflection, my column lengths seems to be incorrect for varchar2, and char columns that are using char storage instead of byte storage. I.E. a VARCHAR2(400 CHAR) colum, is reported to have a length of 1600 by sqlalchemy, as our database uses utf-32 for storage, however, there

[sqlalchemy] Re: Declarative way of delete-orphan

2009-08-26 Thread Mike Conley
Add cascade='delete-orphan' to the relation definition for children. cascade='all,delete-orphan' is also a fairly common option. See the documentation for other options in cascade. http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html#sqlalchemy.orm.relation -- Mike Conley On Wed, Au

[sqlalchemy] Declarative way of delete-orphan

2009-08-26 Thread rajasekhar911
Hi How do i define a delete-orphan using declarative base? I am using sqlite and SA0.5.5 I have defined a one to one relation. class Child(DeclarativeBase): __tablename__='children' id=Column(String(50),primary_key=True) parent_id=Column(String(50),ForeignKey ('parent.id',onupdate="CAS

[sqlalchemy] Re: multiple insert with default values

2009-08-26 Thread menuge
OK. thanks for these answers On Aug 26, 3:42 pm, Mike Conley wrote: > Look at the generated SQL. The Python DBAPI uses one INSERT statement for > all rows inserted when using executemany(). In this case, > INSERT INTO test (col1, col2) VALUES (?, ?) > SA created the column list from the first

[sqlalchemy] Re: from a sqlalchemy table to the corresponding CREATE TABLE sql code

2009-08-26 Thread Michele Simionato
On Aug 26, 3:20 pm, "King Simon-NFHD78" wrote: > > -Original Message- > > From: sqlalchemy@googlegroups.com > > [mailto:sqlalch...@googlegroups.com] On Behalf Of Michele Simionato > > Sent: 26 August 2009 13:40 > > To: sqlalchemy > > Subject: [sqlalchemy] from a sqlalchemy table to the

[sqlalchemy] Temporarily disable FK constraint checks

2009-08-26 Thread babilen
Hi all, i am writing a tool to import MySQL dumps into different databases (MySQL and PostgreSQL). The tool will create suitable databases and tables within them, so i wanted to use metadata.create_all() for table creation. The dumps are in the collowing format: --- snip --- INSERT INTO `catego

[sqlalchemy] Re: multiple insert with default values

2009-08-26 Thread Michael Bayer
On Aug 26, 2009, at 5:36 AM, menuge wrote: > > Hi all, > > I d like to insert a list of dictionary in a simple MySQL table but, I > have a problem, in my case, the MySQL default values are not > supported... > > The table is very simple; 2 columns and a default value on the col2: > ## > CREA

[sqlalchemy] Re: multiple insert with default values

2009-08-26 Thread Mike Conley
Look at the generated SQL. The Python DBAPI uses one INSERT statement for all rows inserted when using executemany(). In this case, INSERT INTO test (col1, col2) VALUES (?, ?) SA created the column list from the first set of values provided to i.insert(), and so supplied a NULL value for col2 in th

[sqlalchemy] Re: from a sqlalchemy table to the corresponding CREATE TABLE sql code

2009-08-26 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:sqlalch...@googlegroups.com] On Behalf Of Michele Simionato > Sent: 26 August 2009 13:40 > To: sqlalchemy > Subject: [sqlalchemy] from a sqlalchemy table to the > corresponding CREATE TABLE sql code > > > A part from se

[sqlalchemy] from a sqlalchemy table to the corresponding CREATE TABLE sql code

2009-08-26 Thread Michele Simionato
A part from setting echo=True and monitoring the result of .create_all, is there a more elegant way to extract the SQL creation code from a table object? TIA, M.S. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] problems with pyscopg2 installed as an egg...

2009-08-26 Thread Chris Withers
Hi All, I'm seeing this error: Module sqlalchemy.engine, line 223, in create_engine Module sqlalchemy.engine.strategies, line 62, in create Module sqlalchemy.databases.postgres, line 361, in dbapi Module None, line 55, in ImportError: cannot import name tz ...when sqlalchemy and ps

[sqlalchemy] multiple insert with default values

2009-08-26 Thread menuge
Hi all, I d like to insert a list of dictionary in a simple MySQL table but, I have a problem, in my case, the MySQL default values are not supported... The table is very simple; 2 columns and a default value on the col2: ## CREATE TABLE `test` ( `col1` int(11) default NULL, `col2` int(1