[sqlalchemy] Re: Operational Error raised by except_

2011-02-22 Thread neurino
I guess since, I learn it now, EXCEPT is not supported by MySQL... I guess I'll have to change my query at all... On Feb 22, 12:57 pm, neurino neur...@gmail.com wrote: I have now problems with except_ in MySQL: the code that worked flawlessly in sqlite now causes an error, seems right after

[sqlalchemy] Unable to select on Table subclass

2011-02-22 Thread bool
I wrote a simple subclass of Table class MyTable(Table): def __init__(self, name, metadata, *args, **kwargs): super(MyTable, self).__init__(name, metadata, *args, **kwargs) def select(self,

[sqlalchemy] Re: Unable to select on Table subclass

2011-02-22 Thread bool
def select(self, whereclause=None): return super(MyTable, self).select(self.c.z 1) You can ignore this method. This error comes with out this method also. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] SqlAlchemy+cx_oracle decimal point problem with stddev

2011-02-22 Thread Massi
Hi everyone, in my script (python 2.6, Oracle10g, cx_oracle 5.0.4, sqlalchemy 0.6.5) I'm running the following simple query on one of my tables: table = Table(my_data_table, metadata, autoload=True) col = getattr(table.c, my_integer_col) res = select(func.stdev(col)).execute().fetchone() where

Re: [sqlalchemy] Unable to select on Table subclass

2011-02-22 Thread Michael Bayer
Table is not meant for subclassing, so you would need to read the source code to understand these issues. The issue below cannot be reproduced: from sqlalchemy import * class MyTable(Table): def __init__(self, name, metadata, *args, **kwargs): super(MyTable, self).__init__(name,

Re: [sqlalchemy] SqlAlchemy+cx_oracle decimal point problem with stddev

2011-02-22 Thread Michael Bayer
Regarding the comma, set NLS_LANG to a locale that uses a decimal point, or use 0.6.6, this behavior is described in the third paragraph at http://www.sqlalchemy.org/docs/dialects/oracle.html#precision-numerics . On Feb 22, 2011, at 8:54 AM, Massi wrote: Hi everyone, in my script (python

Re: [sqlalchemy] Unable to select on Table subclass

2011-02-22 Thread Michael Bayer
On Feb 22, 2011, at 8:30 AM, bool wrote: select(t) where t is an object of MyTable is giving this error. What is the solution... also, I recommend upgrading to a modern release of SQLAlchemy. The above usage produces this error: sqlalchemy.exc.ArgumentError: columns argument to select()

Re: [sqlalchemy] Re: Operational Error raised by except_

2011-02-22 Thread neurino
Something like this: stmt = Session.query(model.ViewOpt.id_cu, model.ViewOpt.id_meas) \ .filter(model.ViewOpt.id_view==1).subquery() query = Session.query(model.Sensor) \ .outerjoin((stmt, and_(model.Sensor.id_cu==stmt.c.id_cu,

[sqlalchemy] Create Database trought sqlalchemy 0.6.6 !

2011-02-22 Thread Toninho Nunes
Hi, I would like to know how to create database with sqlalchemy using the PostGresql driver, are there a sample or example? sqlalchemy just only works with database postgresql previous created. see my code: import sqlalchemy from sqlalchemy import create_engine, Table, MetaData, Integer,

[sqlalchemy] Re: adjacency via table

2011-02-22 Thread farcat
thought i'd post the code I came up with for reference: from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker from sqlalchemy.ext.associationproxy import association_proxy Base = declarative_base() def

Re: [sqlalchemy] self-referential relationship w/ declarative style

2011-02-22 Thread Michael Bayer
On Feb 20, 2011, at 10:12 PM, Ryan wrote: I'm attempting a self-referential mapping on a Client object that includes these two columns: id = Column(Integer, primary_key=True) inviter_id = Column(Integer, ForeignKey('users.id'), nullable=True) Started here with no luck: inviter =

Re: [sqlalchemy] Is it possible to have single transaction across several http calls?

2011-02-22 Thread Michael Bayer
Holding open a transaction across several web requests is in general a bad idea. HTTP is stateless - the requests could be spaced hours apart or not at all, leaving the transaction hanging open permanently. While the transaction is open, locks may be held, preventing concurrent activities

Re: [sqlalchemy] commit() okay on every web request ?

2011-02-22 Thread Michael Bayer
calling commit() on every request is fine, as long as you aren't creating unwanted 'dirty' state inadvertently.Watching your SQL logs could help you to determine if things are happening that are undesirable. On Feb 21, 2011, at 3:38 AM, Romy wrote: Switched to autocommit=False, and

[sqlalchemy] Small docs problem

2011-02-22 Thread Christoph Zwerschke
Just noticed that the 0.6.6 docs show a name parameter of subquery(), but it does not yet seem to be available in 0.6.6. There should be a note that it can only be used in 0.6.7 or 0.7. -- Christoph -- You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Re: Create Database trought sqlalchemy 0.6.6 !

2011-02-22 Thread Eric Ongerth
sqlalchemy allows you to issue any literal sql statements as text: http://www.sqlalchemy.org/docs/core/tutorial.html#using-text On Feb 22, 7:38 am, Toninho Nunes toninhonu...@gmail.com wrote: Hi, I would like to know how to create database with sqlalchemy using the PostGresql driver, are

[sqlalchemy] Re: Create Database trought sqlalchemy 0.6.6 !

2011-02-22 Thread Eric Ongerth
Even with that autocommit transaction isolation level, you probably need to commit the create database before you try to add tables to it. On Feb 22, 1:45 pm, Toninho Nunes toninhonu...@gmail.com wrote: Hi see my source code below import sqlalchemy import psycopg2 from sqlalchemy import

Re: [sqlalchemy] PostgreSQL BIT type not properly supported by dialect

2011-02-22 Thread Michael Bayer
this has been fixed in 0.7, however it is completely a mystery how the change got in there, and it doesn't have test coverage. I'm thinking perhaps someone on IRC handed me a patch or something and I forgot it was there since it was committed along with something not really related:

Re: [sqlalchemy] self-referential relationship w/ declarative style

2011-02-22 Thread Michael Bayer
On Feb 22, 2011, at 9:03 PM, Ryan McKillen wrote: Mike, thanks a lot. Big help. I'm almost there. This seems to do the trick: usersid = Column(Integer, primary_key=True, key='id') inviter_id = Column(Integer, ForeignKey('users.id')) inviter = relationship('User',

Re: [sqlalchemy] Re: Create Database trought sqlalchemy 0.6.6 !

2011-02-22 Thread Michael Bayer
Setting an autocommit setting on a single raw_connection() won't work also because that's just one connection out of several in the pool. The operation should be performed on a Connection: c = engine.connect() c.detach() # so it is never returned to the pool, since we're changing settings

Re: [sqlalchemy] self-referential relationship w/ declarative style

2011-02-22 Thread Ryan McKillen
I added that in because without it I get: TypeError: Incompatible collection type: User is not list-like On Tue, Feb 22, 2011 at 6:47 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Feb 22, 2011, at 9:03 PM, Ryan McKillen wrote: Mike, thanks a lot. Big help. I'm almost there. This

Re: [sqlalchemy] self-referential relationship w/ declarative style

2011-02-22 Thread Michael Bayer
one side scalar, one side collection. the collection side you use .append(). You decide which end is the non-collection by setting remote_side, in your code below its invitee. On Feb 22, 2011, at 9:59 PM, Ryan McKillen wrote: I added that in because without it I get: TypeError:

Re: [sqlalchemy] self-referential relationship w/ declarative style

2011-02-22 Thread Ryan McKillen
Got it. Many thanks! On Tue, Feb 22, 2011 at 7:02 PM, Michael Bayer mike...@zzzcomputing.comwrote: one side scalar, one side collection. the collection side you use .append(). You decide which end is the non-collection by setting remote_side, in your code below its invitee. On Feb

[sqlalchemy] Re: Create Database trought sqlalchemy 0.6.6 !

2011-02-22 Thread Toninho Nunes
You are right, but I would like to create the database without to connect to other database existent, I'm newbie learning python and sqlalchemy. any example will be welcome. Thanks a lot On Feb 22, 6:06 pm, Warwick Prince warwi...@mushroomsys.com wrote: Hi Toninho Looks to me that the issue