[sqlalchemy] VARCHAR(None CHAR)

2013-11-22 Thread Jose Soares
Hi all, I have a query generated by sqlalchemy like this: SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento, fattura_master.sezionale || '/' || CAST(fattura_master.anno AS VARCHAR(None CHAR)) || '/' || CAST(fattura_master.numero AS VARCHAR(None CHAR)) AS pk FROM

Re: [sqlalchemy] [wishlist] ORM/engine Feature Request - comment(), explain()?

2013-11-22 Thread Chris Withers
I saw this thread and had been thinking of something similar... ...a query.explain() that would run an explain of the query, log the output somewhere and then return the query so you could do: query.explain().all() ...and the like. Is there a similar recipe for logging the query and its

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-22 Thread Chris Withers
On 21/11/2013 19:25, Michael Bayer wrote: hoping you’ve already figured it out but otherwise I’m not entirely following what the larger query you’re looking for would look like.I doubt you need text() for anything. Okay, pseudo code that doesn't work: positions = something( select

[sqlalchemy] SQLite temporary tables

2013-11-22 Thread Gombas, Gabor
Hi, How should one create SQLite temporary tables using SQLAlchemy? The following does not work: from sqlalchemy import create_engine, Column, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from

Re: [sqlalchemy] SQLite temporary tables

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 6:24 AM, Gombas, Gabor gabor.gom...@morganstanley.com wrote: Hi, How should one create SQLite temporary tables using SQLAlchemy? The following does not work: from sqlalchemy import create_engine, Column, String from sqlalchemy.ext.declarative import

Re: [sqlalchemy] [wishlist] ORM/engine Feature Request - comment(), explain()?

2013-11-22 Thread Michael Bayer
yes that is here: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Explain comments: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionModifiedSQL feel free to combine On Nov 22, 2013, at 5:12 AM, Chris Withers ch...@simplistix.co.uk wrote: I saw this thread and had been thinking

Re: [sqlalchemy] VARCHAR(None CHAR)

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 4:50 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, I have a query generated by sqlalchemy like this: SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento, fattura_master.sezionale || '/' || CAST(fattura_master.anno AS VARCHAR(None CHAR))

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 5:06 AM, Chris Withers ch...@simplistix.co.uk wrote: On 21/11/2013 19:25, Michael Bayer wrote: hoping you’ve already figured it out but otherwise I’m not entirely following what the larger query you’re looking for would look like.I doubt you need text() for

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-22 Thread Chris Withers
On 22/11/2013 15:23, Michael Bayer wrote: (this latter query will likely have more stuff in it, not sure I used .select_from(...).join(...) correctly either ;-) Hope that illustrates what I'm after… take your original cte and use it just like that, just call positions.c.instrument_id for

Re: [sqlalchemy] VARCHAR(None CHAR)

2013-11-22 Thread Jose Soares
Ok. It works, thanks, Michael j On 11/22/2013 04:22 PM, Michael Bayer wrote: On Nov 22, 2013, at 4:50 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, I have a query generated by sqlalchemy like this: SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento,

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 10:31 AM, Chris Withers ch...@simplistix.co.uk wrote: On 22/11/2013 15:23, Michael Bayer wrote: (this latter query will likely have more stuff in it, not sure I used .select_from(...).join(...) correctly either ;-) Hope that illustrates what I'm after… take your

[sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-22 Thread Ivan Kalinin
Hello there, fellow developers! We've recently run into a terrible problem. A small tool uses SQLAlchemy to execute statements read from a text file against a database. The trouble comes when that pre-defined statement has a colon symbol in the field value of a, say, INSERT statement. Like

Re: [sqlalchemy] Running an externally supplied SQL statement with special characters

2013-11-22 Thread Michael Bayer
On Nov 22, 2013, at 1:11 PM, Ivan Kalinin pupss...@gmail.com wrote: Hello there, fellow developers! We've recently run into a terrible problem. A small tool uses SQLAlchemy to execute statements read from a text file against a database. The trouble comes when that pre-defined

RE: [sqlalchemy] SQLite temporary tables

2013-11-22 Thread Gombas, Gabor
That works, thanks. Currently, I'm using __declare_last__() to modify __table__.schema (SQLite) or __table__._prefixes (Oracle, PostgreSQL), once the dialect is known. For the latter two I'm also monkey-patching post_create_table(), which seemed easier to do than to completely re-implement

Re: [sqlalchemy] SQLite temporary tables

2013-11-22 Thread Michael Bayer
OK you can also use @compiles on top of CreateTable to get directly at that process. On Nov 22, 2013, at 4:34 PM, Gombas, Gabor gabor.gom...@morganstanley.com wrote: That works, thanks. Currently, I'm using __declare_last__() to modify __table__.schema (SQLite) or __table__._prefixes