[sqlalchemy] Re: autocommit on for DDL
You might be interested to know that the situation is more like If you are not using MySQL, you probably have transactional DDL. Even SQLite has it. According to http://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis - PostgreSQL - yes - MySQL - no; DDL causes an implicit commit - Oracle Database 11g Release 2 and above - yes (something called edition-based redefinition) - Older versions of Oracle - no; DDL causes an implicit commit - SQL Server - yes - Sybase Adaptive Server - yes - DB2 - yes - Informix - yes - Firebird (Interbase) - yes -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] pickling an engine onject
Hi, I saw that there is a way to serialize a query object is there a way to serialize an engine object? Thanks -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] pickling an engine onject
assuming you saw : http://www.sqlalchemy.org/docs/core/serializer.html for serializing queries. engines can't be serialized since TCP connections don't support it.You can only do memoization tricks like those in the serializer extension to create/locate a new engine on the other side. On Jan 28, 2011, at 10:49 AM, Eduardo wrote: Hi, I saw that there is a way to serialize a query object is there a way to serialize an engine object? Thanks -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Compound Join
Michael, Thanks for the quick reply. The one thing I hadn't tried was doing a separate join for each of the primary table joins and once I did that it worked. It dawned on me this morning that I forgot to mention I was using ORM syntax, but you got the answer out before I had a chance to update the original post. Thanks again, - Eric On Jan 27, 7:02 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 27, 2011, at 8:06 PM, Eric N wrote: I'm trying to construct a query where in the from clause I would end up with something like SELECT foo FROM table1 JOIN table2 ON table1.id1 = table2.id1 JOIN table3 ON table1.id1=table3.id1 JOIN table4 ON table2.id2=table4.id2 AND table3.id3=table4.id3 I have tried various join combinations but I can only get it to join table4 to table2 or table 3, not both. the and_() function would be used as the onclause: from sqlalchemy import and_ select = select.select_from( table1.join(table2, table2.c.id1==table1.c.id1).\ join(table3, table1.c.id1==table3.c.id1).\ join(table4, and_(table2.c.id2==table4.c.id2, table3.c.id3==table4.c.id3)) ) You didn't say if you were using ORM or expression language, that above is expression language. Same idea applies to ORM, use and_() in the ON clause. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] how to build up an or_ clause programmatically?
Hi, I would like to build an or_ statement using a for cycle, something like the following: employeetask_or = or_(False) # to exclude everything not satisfied by later appended criteria, is this needed or empty or_() is fine? for period in periods.all(): period.close(session, machine_id) employeetask_or.append(and_(EmployeeTasks.work_id==period.operation.work_id, EmployeeTasks.is_reparation==period.operation.is_reparation)) qry = session.query(EmployeeTasks).filter(and_(employeetask_or, EmployeeTasks.paused==None, EmployeeTasks.finished==0)) of course(?) this does not work, and I don't really have any ideas after inspecting or_'s methods. Could someone give me a hand, please? (this inefficient for cycle is needed for a very efficient bulk update) Viktor -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: how to build up an or_ clause programmatically?
I've just found http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg14672.html what answers my question. sorry for bothering you On Fri, Jan 28, 2011 at 9:36 PM, Viktor Nagy viktor.n...@toolpart.huwrote: Hi, I would like to build an or_ statement using a for cycle, something like the following: employeetask_or = or_(False) # to exclude everything not satisfied by later appended criteria, is this needed or empty or_() is fine? for period in periods.all(): period.close(session, machine_id) employeetask_or.append(and_(EmployeeTasks.work_id==period.operation.work_id, EmployeeTasks.is_reparation==period.operation.is_reparation)) qry = session.query(EmployeeTasks).filter(and_(employeetask_or, EmployeeTasks.paused==None, EmployeeTasks.finished==0)) of course(?) this does not work, and I don't really have any ideas after inspecting or_'s methods. Could someone give me a hand, please? (this inefficient for cycle is needed for a very efficient bulk update) Viktor -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Sqlite3 auto
Hi, [] I'm trying to create tables in SQLITE, with a composite PK (id, eid), I want the id have the auto increment. I've read this, http://www.sqlalchemy.org/docs/dialects/sqlite.html#auto-incrementing-behavior, and following your instructions, added __table_args__ = {'sqlite_autoincrement':True} (I'm using declarative), but i'm not having any difference. This is the debug exit and the declarative code: 2011-01-28 13:48:56,999 INFO sqlalchemy.engine.base.Engine.0x...b9ec CREATE TABLE elementos_filiales ( id INTEGER, tipo TEXT, timestamp TEXT, eid VARCHAR(127) NOT NULL, nombre TEXT, eliminado INTEGER, padre INTEGER, PRIMARY KEY (id, eid), FOREIGN KEY(padre) REFERENCES elementos_multinacionales (id) ) id = Column(Integer,primary_key=True,nullable=True) eid = Column(String(132),primary_key=True) What i'm doing wrong? Thank you. -- Alex. Slothy, the Angry Wombat http://angrywombat.comuv.com/portfolio/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Sqlite3 auto
On Jan 28, 2011, at 8:07 AM, slothy Rulez a lot wrote: Hi, [] I'm trying to create tables in SQLITE, with a composite PK (id, eid), I want the id have the auto increment. I've read this, http://www.sqlalchemy.org/docs/dialects/sqlite.html#auto-incrementing-behavior, and following your instructions, added __table_args__ = {'sqlite_autoincrement':True} (I'm using declarative), but i'm not having any difference. This is the debug exit and the declarative code: 2011-01-28 13:48:56,999 INFO sqlalchemy.engine.base.Engine.0x...b9ec CREATE TABLE elementos_filiales ( id INTEGER, tipo TEXT, timestamp TEXT, eid VARCHAR(127) NOT NULL, nombre TEXT, eliminado INTEGER, padre INTEGER, PRIMARY KEY (id, eid), FOREIGN KEY(padre) REFERENCES elementos_multinacionales (id) ) What you are trying to do won't work in SQLite because INTEGER PRIMARY KEY is an alias for a special SQLite ROWID. So, when you create a two-column primary key, you lose the ROWID alias feature. AUTOINCREMENT can apparently only be used with a single-column primary key: sqlite create table gonk(a INTEGER AUTOINCREMENT,b varchar,primary key(a,b)); Error: near AUTOINCREMENT: syntax error sqlite create table gonk(a INTEGER PRIMARY KEY AUTOINCREMENT,b varchar,primary key(a,b)); Error: table gonk has more than one primary key However, you should be able to create a table having id as the primary key and a unique constraint on (id,eid) which should be effectively the same. Cheers, M -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.