[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-18 Thread Ygor Lemos
If anybody else is experience the same problem, I have opened a Bug Request @ SQLA Trac, you can follow it through here: http://www.sqlalchemy.org/trac/ticket/2260 On Aug 18, 1:56 am, Ygor Lemos opti...@gmail.com wrote: Oh, sorry about that, I copied from a previous declaration I've been

[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-18 Thread Ygor Lemos
If anybody else is experiencing this same problem, I have opened a Bug Request @ SQLA Trac and you can follow it through here: http://www.sqlalchemy.org/trac/ticket/2260 On Aug 18, 1:56 am, Ygor Lemos opti...@gmail.com wrote: Oh, sorry about that, I copied from a previous declaration I've

[sqlalchemy] event.remove failure

2011-08-18 Thread sandro dentella
Hi, I started to play with events to port a library to sqla 0.7. I managed to use the 'listen' function but I failed on 'remove'. Looking at the signatures they seem to be just the same, but here is what I get: In [7]: event.listen(obj.__class__.title, 'set', listen_cb) In [8]:

Re: [sqlalchemy] event.remove failure

2011-08-18 Thread Michael Bayer
remove() isn't implemented yet.While the simple operation you see below would be fine for a single listener on a single target, the targets we have which propagate to subclasses (mapper events, attribute events) would require a more elaborate system that can revisit everywhere the event has

[sqlalchemy] Mapping a CTE

2011-08-18 Thread Marc DellaVolpe
I found the following CTE demo (http://www.sqlalchemy.org/trac/ attachment/ticket/1859/cte_demo.py) and I was wondering if there was any way to map these selects. I have built a CTE based select to generate a dates table on the fly and I would love to be able to map this and use generative

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 11:23 AM, Marc DellaVolpe wrote: I found the following CTE demo (http://www.sqlalchemy.org/trac/ attachment/ticket/1859/cte_demo.py) and I was wondering if there was any way to map these selects. I have built a CTE based select to generate a dates table on the fly and

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Marc DellaVolpe
I should have mentioned, I modified the CTE demo to work on SQL Server and I believe (I will double check this...) that on SQL Server the with of the CTE needs to be at the top of the statement and referenced in subqueries below. The generated SQL SELECT FROM (WITH ...) is invalid on SQL

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 11:56 AM, Marc DellaVolpe wrote: I should have mentioned, I modified the CTE demo to work on SQL Server and I believe (I will double check this...) that on SQL Server the with of the CTE needs to be at the top of the statement and referenced in subqueries below. The

[sqlalchemy] InsertFromSelect on SQL server

2011-08-18 Thread Massi
Hi everyone, I'm trying to implement an InsertFromSelect workaround to handle the identity insert issue of SQL server. This is more or less what I'm doing: class InsertFromSelect(Executable, ClauseElement) : def __init__(self, table, select) : self.table = table self.select =

Re: [sqlalchemy] InsertFromSelect on SQL server

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 12:24 PM, Massi wrote: Hi everyone, I'm trying to implement an InsertFromSelect workaround to handle the identity insert issue of SQL server. This is more or less what I'm doing: class InsertFromSelect(Executable, ClauseElement) : def __init__(self, table, select) :

[sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Massi
I changed the code to (SA 0.7.2 with pyodbc2.1.9): class InsertFromSelect(Executable, ClauseElement) : _execution_options =\ Executable._execution_options.union({'autocommit': True}) def __init__(self, table, select) : self.table = table self.select = select

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Marc DellaVolpe
From what I can tell from http://msdn.microsoft.com/en-us/library/ms190766.aspx and experimentally, you can only put CTE's at the top: -- Works WITH all_dates(date) AS ( SELECT CAST('2011-01-01' AS DATETIME) AS anon_1 UNION ALL SELECT DATEADD(dd, 1, date) AS DATEADD_1 FROM all_dates WHERE

Re: [sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 1:06 PM, Massi wrote: I changed the code to (SA 0.7.2 with pyodbc2.1.9): class InsertFromSelect(Executable, ClauseElement) : _execution_options =\ Executable._execution_options.union({'autocommit': True}) def __init__(self, table, select) : self.table =

[sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Massi
I got: File C:\Python26\lib\site-packages\sqlalchemy-0.7.2-py2.6-win32.egg \sqlalchemy\engine\base.py, line 2285, in execute return connection.execute(statement, *multiparams, **params) File C:\Python26\lib\site-packages\sqlalchemy-0.7.2-py2.6-win32.egg \sqlalchemy\engine\base.py, line

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Marc DellaVolpe
There seems to be a problem with the custom compilation. print Session.query(Date).order_by(Date.date.desc()) WITH all_dates(date) AS ( SELECT CAST(:start AS DATETIME) AS anon_1 UNION ALL SELECT DATEADD(dd, :step, date) AS DATEADD_1 FROM all_dates WHERE DATEADD(dd, :step, date) = CAST(:stop AS

Re: [sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 1:19 PM, Massi wrote: I got: File C:\Python26\lib\site-packages\sqlalchemy-0.7.2-py2.6-win32.egg \sqlalchemy\engine\base.py, line 2285, in execute return connection.execute(statement, *multiparams, **params) File

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 1:28 PM, Marc DellaVolpe wrote: There seems to be a problem with the custom compilation. print Session.query(Date).order_by(Date.date.desc()) WITH all_dates(date) AS ( SELECT CAST(:start AS DATETIME) AS anon_1 UNION ALL SELECT DATEADD(dd, :step, date) AS DATEADD_1

Re: [sqlalchemy] Mapping a CTE

2011-08-18 Thread Marc DellaVolpe
I understand what you are saying about this being an uphill battle on mssql. If we ignore the CTE for the moment and pretend that all_dates is a regular table, shouldn't there be no difference for generation. You can subquery as needed and all that really needs to happen is to prepend the CTE

[sqlalchemy] Weird bug

2011-08-18 Thread brianhawthorne
Hello, I have found a case where instantiating a select statement during the declaration of the parent class in a one-to-many pair can cause a downstream failure to generate well formed sql when performing a query with a subqueryload option. I've boiled down a minimal example (pasted below) which

Re: [sqlalchemy] Weird bug

2011-08-18 Thread Michael Bayer
the issue is quite simple as can be seen in this demonstration: from sqlalchemy import * # two columns. Nothing up my sleeve ! c1 = Column('c1', Integer) c2 = Column('c2', Integer) # put one of them into a Select. # generate _from_objects collection of c1 too early s = select([c1]) t =

Re: [sqlalchemy] Weird bug

2011-08-18 Thread Michael Bayer
On Aug 18, 2011, at 4:24 PM, Michael Bayer wrote: However, the original select() is still wrong. _from_objects gave it the wrong data, period.How to guard against this issue, a potentially expensive reorg of Select internals. As well as future issues of this sort, using Column

[sqlalchemy] Re: event.remove failure

2011-08-18 Thread sandro dentella
On 18 Ago, 16:52, Michael Bayer mike...@zzzcomputing.com wrote: remove() isn't implemented yet.    While the simple operation you see below would be fine for a single listener on a single target, the targets we have which propagate to subclasses (mapper events, attribute events) would

[sqlalchemy] Repetitive Fields in declarative

2011-08-18 Thread Mark Erbaugh
I want to create a table that has several similar fields. For example, assume the fields are field1, field2, ... Is there a way in the declarative class that I can do something like: for i in range(10): 'field%d' % i = Column( ... ) Thanks, Mark -- You received this message because

Re: [sqlalchemy] Repetitive Fields in declarative

2011-08-18 Thread Mark Erbaugh
On Aug 18, 2011, at 6:06 PM, Mark Erbaugh wrote: want to create a table that has several similar fields. For example, assume the fields are field1, field2, ... Is there a way in the declarative class that I can do something like: for i in range(10): 'field%d' % i = Column( ... )

Re: [sqlalchemy] Repetitive Fields in declarative

2011-08-18 Thread Mark Erbaugh
Me again (see below): On Aug 18, 2011, at 7:01 PM, Mark Erbaugh wrote: On Aug 18, 2011, at 6:06 PM, Mark Erbaugh wrote: want to create a table that has several similar fields. For example, assume the fields are field1, field2, ... Is there a way in the declarative class that I can do