[sqlalchemy] postgres character(num) issue

2010-04-15 Thread Eric Lemoine
Hi I use PostgreSQL and I have this column if one of my tables: ens character(60). I use autoload in my model for that table. SQLAlchemy 0.5.8 always gives me strings with 60 characters (with trailing spaces) when doing queries. I wouldn't expect that. Is there a way to change that behavior?

[sqlalchemy] postgresql column default

2010-04-15 Thread Michael Brickenstein
Hi! I have reflected my table from the db (Postgresql 8.4.2, tried psyco 2.0.12 and 2.0.14) using Table(name, metadata, autoload=True, autoload_with=engine) After that I map the table. When later in my app, I try to access the default values from the DB, I use the columnproperty: from

RE: [sqlalchemy] flush(), save(), delete()

2010-04-15 Thread King Simon-NFHD78
Jo wrote: [SNIP] and- In [13]: aa=Anagrafica.get(111) In [14]: aa.delete() In [15]: aa.flush() - but in version 0.6 I can't find flush(), save(),

[sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Brickenstein
Sorry, forgot to mention, I had the same behaviour with SA 0.5.6 and 0.5.8. Cheers, Michael On 15 Apr., 12:27, Michael Brickenstein brickenst...@mfo.de wrote: Hi! I have reflected my table from the db (Postgresql 8.4.2, tried psyco 2.0.12 and 2.0.14) using Table(name, metadata,

[sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Brickenstein
On 15 Apr., 13:03, Michael Brickenstein brickenst...@mfo.de wrote: Sorry, forgot to mention, I had the same behaviour with SA 0.5.6 and 0.5.8. Cheers, In former times, I used prop.server_default to find out, that there is an default of ''. Sorry, that's wrong it has always been the

Re: [sqlalchemy] postgres character(num) issue

2010-04-15 Thread Michael Bayer
you'd use VARCHAR, CHAR is fixed width. If you want to force it, use a TypeDecorator that calls strip() on the returned values. On Apr 15, 2010, at 5:28 AM, Eric Lemoine wrote: Hi I use PostgreSQL and I have this column if one of my tables: ens character(60). I use autoload in my model

Re: [sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Bayer
On Apr 15, 2010, at 7:26 AM, Michael Brickenstein wrote: On 15 Apr., 13:03, Michael Brickenstein brickenst...@mfo.de wrote: Sorry, forgot to mention, I had the same behaviour with SA 0.5.6 and 0.5.8. Cheers, In former times, I used prop.server_default to find out, that there is an

Re: [sqlalchemy] postgres character(num) issue

2010-04-15 Thread Eric Lemoine
On Thu, Apr 15, 2010 at 2:12 PM, Michael Bayer mike...@zzzcomputing.com wrote: you'd use VARCHAR, CHAR is fixed width.   If you want to force it, use a TypeDecorator that calls strip() on the returned values. Yes, thanks. I got confused because of the concat operator (||) in PostgreSQL. The

[sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Chris Withers
Hi All, I have a big set of queries provided as raw sql like: SELECT somestuff FROM somewhere WHERE some_date = :from_date AND some_date = :to_date That's fine, I just blat it at session.execute and provide from_date and to_date in the params dict. However, they now wany to supply

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Michael Bayer
you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. On Apr 15, 2010, at 9:54 AM, Chris Withers wrote: Hi All, I have a big set of queries provided as raw sql like: SELECT somestuff FROM somewhere WHERE some_date = :from_date AND

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Chris Withers
Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values, they don't, and it may vary from when they write the SQL to when that SQL gets executed by my code... Chris -- You

[sqlalchemy] column_prefix

2010-04-15 Thread jo
Hi all, Module sqlalchemy.engine.base:*1180* in |__execute_context ||context*.*parameters*[**0**]**,* context*=*context*)*| Module sqlalchemy.engine.base:*1249* in |_cursor_execute|| self*.*_handle_dbapi_exception*(*e*,* statement*,* parameters*,* cursor*,* context*)*| Module

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Michael Bayer
yeah man , this is why we're all moving to mongodb :) On Apr 15, 2010, at 10:46 AM, Chris Withers wrote: Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values,

Re: [sqlalchemy] column_prefix

2010-04-15 Thread Michael Bayer
If you could send code examples in a readable format, that would be helpful. Here is column_prefix working as documented: from sqlalchemy import * from sqlalchemy.orm import * engine = create_engine('sqlite://', echo=True) metadata = MetaData() t = Table('foo', metadata, Column('id',

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Mariano Mara
Excerpts from Chris Withers's message of Thu Apr 15 11:46:05 -0300 2010: Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values, they don't, and it may vary from when

RE: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Mariano Mara Sent: 15 April 2010 16:20 To: sqlalchemy Subject: Re: [sqlalchemy] further restricting a query provided as raw sql Excerpts from Chris Withers's message of Thu

Re: [sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Brickenstein
Hi! Thanks for your very prompt answer. Unluckily, my mails were a little bit unprecise: So, I wondered why the following happened: prop = get_mapper(Participation).get_property('remark') c=prop.columns[0] c Column(u'remark', PGText(length=None, convert_unicode=False, assert_unicode=None),

[sqlalchemy] Re: DropConstraint exception

2010-04-15 Thread Gerry Reno
Upgraded to beta3. So you're saying that if we want to be able to drop a constraint later on we must create it with a name. Alright. But I am still getting an Operational Error: #!/usr/bin/env python import sqlalchemy from sqlalchemy import

[sqlalchemy] 2 Sessions with same object...how do they interact?

2010-04-15 Thread NickPerkins
Just when I thought I understood the Session object, I found this behavior: ( I am starting to think about concurrency and locking ) I create 2 sessions, and load each with the same ( persisted ) object. The objects appear to be independent, even after both sessions have flushed, but when I

Re: [sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Bayer
On Apr 15, 2010, at 11:35 AM, Michael Brickenstein wrote: Hi! Thanks for your very prompt answer. Unluckily, my mails were a little bit unprecise: So, I wondered why the following happened: prop = get_mapper(Participation).get_property('remark') c=prop.columns[0] c

Re: [sqlalchemy] Re: DropConstraint exception

2010-04-15 Thread Michael Bayer
On Apr 15, 2010, at 11:46 AM, Gerry Reno wrote: Upgraded to beta3. So you're saying that if we want to be able to drop a constraint later on we must create it with a name. Alright. But I am still getting an Operational Error:

Re: [sqlalchemy] 2 Sessions with same object...how do they interact?

2010-04-15 Thread Conor
NickPerkins wrote: Just when I thought I understood the Session object, I found this behavior: ( I am starting to think about concurrency and locking ) I create 2 sessions, and load each with the same ( persisted ) object. The objects appear to be independent, even after both sessions have

[sqlalchemy] Re: DropConstraint exception

2010-04-15 Thread Gerry Reno
Yep. Works with postgresql: $ python /tmp/testthis.py 2010-04-15 12:40:03,032 INFO sqlalchemy.engine.base.Engine.0x...240c select version() 2010-04-15 12:40:03,032 INFO sqlalchemy.engine.base.Engine.0x...240c {} 2010-04-15 12:40:03,053 INFO sqlalchemy.engine.base.Engine.0x...240c select

Re: [sqlalchemy] Concrete table inheritance without a master table

2010-04-15 Thread WDyk
Each of the four tables for the networknode subclasses have hundreds of columns, but each has an mid column and a typename column. Here's the definition of connecttb, thanks to sqlautocode: connecttb = Table('connecttb', metadata, Column(u'deleteflag', Numeric(precision=10, scale=2,

Re: [sqlalchemy] Concrete table inheritance without a master table

2010-04-15 Thread Michael Bayer
On Apr 15, 2010, at 2:16 PM, w...@nobleenergyinc.com wrote: Adding concrete=True got rid of the specific error listed. The problem I face now is the relation between connecttb and productionentities. How can I specify this relationship? I tried again and specified the relationships on

[sqlalchemy] Re: DropConstraint exception

2010-04-15 Thread Gerry Reno
Except if I reflect the tables in existing db where constraints are all named and then try: from sqlalchemy.schema import DropConstraint for table in metadata.tables.keys():     for con in metadata.tables[table].constraints:         if isinstance(con, PrimaryKeyConstraint):            

Re: [sqlalchemy] Re: DropConstraint exception

2010-04-15 Thread Michael Bayer
On Apr 15, 2010, at 3:21 PM, Gerry Reno wrote: Except if I reflect the tables in existing db where constraints are all named and then try: from sqlalchemy.schema import DropConstraint for table in metadata.tables.keys(): for con in metadata.tables[table].constraints: if

[sqlalchemy] Re: 2 Sessions with same object...how do they interact?

2010-04-15 Thread NickPerkins
I am using SQLite. I can see the COMMIT, and there is only one. The SQL log shows that the COMMIT is immediately followed by a retrieve of the same row, but it's retrieving a value that was flushed ( but not committed ) from a different session! So, are these 2 sessions connected to the same

Re: [sqlalchemy] Re: 2 Sessions with same object...how do they interact?

2010-04-15 Thread Michael Bayer
SQLite uses the singleton thread pool by default which shares one connection per thread.This so that a :memory: connection works as expected. There's a good deal of discussion and advice on this topic at

[sqlalchemy] adapt MSVarchar to SLString

2010-04-15 Thread Tony
I was trying to copy a MS Sql server database to a Sqlite database (with SA 5.8), and get this exception: return typeobj.adapt(impltype) File C:\Python25\lib\site-packages\sqlalchemy\databases\mssql.py, line 685, in adapt collation=self.collation) TypeError: __init__() got an unexpected

Re: [sqlalchemy] Re: postgresql column default

2010-04-15 Thread Michael Brickenstein
Hi! Thanks, that was very helpful for me. Cheers, Michael Am 15.04.2010 um 18:17 schrieb Michael Bayer: this column is against an alias, which suggests you've mapped to an alias() or select() of some kind. To get at full table metadata you need to be talking to Column objects that are