[sqlalchemy] Re: Unnecessary join in eager one-to-many backref

2009-08-04 Thread Martin Stein
On Aug 3, 5:07 pm, Michael Bayer mike...@zzzcomputing.com wrote: Ok that's kind of interesting.   as a general rule, the ORM doesn't like to make assumptions.  such as here, there is a lazyloader on User.keywords, which says query for these Keyword objects, without any knowledge of what

[sqlalchemy] Specify join_depth with eagerload()

2009-08-04 Thread Kees van den Broek
Hi, All the information I need, I can get in 1 SQL query with this query and model: categories=Article.query.filter(Article.parent == None).all() class Article(DefaultEntity): name = Field(Unicode(64), index=True) parent = ManyToOne('Article') children = OneToMany('Article',

[sqlalchemy] MySQL DDL broken with autoincrement-column in multipart-key using InnoDB

2009-08-04 Thread Christian Schwanke
I'm using MySQL and want to use a combined primary-key where the second column is autogenerated while the first part is an assigned value. This is how my Table-definition looks like: table_a = Table('table_a', metadata, Column('assigned_id', Integer(), primary_key=True, autoincrement=False),

[sqlalchemy] to_char

2009-08-04 Thread ast
Hello M trying to use to_char function which works on postgres but gives error on mysql. My code is import sqlalchemy from sqlalchemy import * engine = sqlalchemy.create_engine(mysql://root:r...@localhost:3306/ newdb,echo=True) meta = MetaData(engine) t1 = Table(Table1,meta) id =

[sqlalchemy] Re: Firebird - called a stored procedure which returns a value

2009-08-04 Thread Werner F. Bruhin
Figured out how to run the called procedure. sql = db.sa.text(select trans_value from t(:totrans, :username), bindparams=[db.sa.bindparam('totrans', 'some text orig'), db.sa.bindparam('username', me.name)]) result =

[sqlalchemy] Re: Declarative base and Adjacency List Relationships

2009-08-04 Thread Werner F. Bruhin
Hi, maxi wrote: Hi, I´ve just using sqlalchemy 0.5.1 with python 2.6 and turbogers, but I found a little problem trying to configurate adjacency relationship with declarative base. My object class is something like this: class QueryGroup(DeclarativeBase): __tablename__ =

[sqlalchemy] Accessing attributes hidden by a join

2009-08-04 Thread Nathan Harmston
Hi everyone, I am trying to get access to attributes which are hidden by a join: I have two tables intervals_table = Table(intervals, metadata, Column(interval_id, Integer, primary_key=True), Column(sentence_id, Integer,

[sqlalchemy] Re: Accessing attributes hidden by a join

2009-08-04 Thread Mike Conley
Did you consider using the mapper mapper(Entity, entities_table, properties={ 'interval' : relation(Interval) }) instead of the join()? Optional arguments on the relation can control things like lazy vs eager loading, and scalar vs list for 1-1 or 1-n relationships. If you need to use

[sqlalchemy] can I specifiy a postgres bigint using declarative_base?

2009-08-04 Thread sim
Just started with SQLAlchemy, been great so far but have been tripped up by the following; Using the standard ORM stuff of; Base = declarative_base() class Temp(Base): __tablename__ = 'temp' somecol = Column('somecol', Integer) In posgres this declares 'somecol' as an `integer' but I

[sqlalchemy] Session will not commit within a class

2009-08-04 Thread kportertx
for some reason I cannot get my session to commit within a class Here is the error. Traceback (most recent call last): File /usr/local/lib/python2.6/dist-packages/cherrypy/ _cprequest.py, line 606, in respond cherrypy.response.body = self.handler() File

[sqlalchemy] Alchemy + Firebird Generators

2009-08-04 Thread León
Hi, does anybody know how can I use the default param in the Column class to define a new value which comes from a Firebird generator? I get the same thing with cod_objeto = self.conexion.execute('SELECT FIRST 1 NEXT VALUE FOR GEN_ %d FROM RDB$DATABASE' % cod_clase).fetchone()[0]

[sqlalchemy] Re: Specify join_depth with eagerload()

2009-08-04 Thread Michael Bayer
eagerload() doesn't need join_depth. it will eagerload what you tell it to, i.e. query.options(eagerload_all('Article', 'Article', 'Article')) Kees van den Broek wrote: Hi, All the information I need, I can get in 1 SQL query with this query and model:

[sqlalchemy] Netezza

2009-08-04 Thread dusans
Is there a possibility to connect to Netezza db server? --~--~-~--~~~---~--~~ 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

[sqlalchemy] Re: MySQL DDL broken with autoincrement-column in multipart-key using InnoDB

2009-08-04 Thread Michael Bayer
Christian Schwanke wrote: I'm using MySQL and want to use a combined primary-key where the second column is autogenerated while the first part is an assigned value. This is how my Table-definition looks like: table_a = Table('table_a', metadata, Column('assigned_id', Integer(),

[sqlalchemy] Re: to_char

2009-08-04 Thread Michael Bayer
ast wrote: Hello M trying to use to_char function which works on postgres but gives error on mysql. My code is import sqlalchemy from sqlalchemy import * engine = sqlalchemy.create_engine(mysql://root:r...@localhost:3306/ newdb,echo=True) meta = MetaData(engine) t1 =

[sqlalchemy] Re: Firebird - called a stored procedure which returns a value

2009-08-04 Thread Michael Bayer
Werner F. Bruhin wrote: Figured out how to run the called procedure. sql = db.sa.text(select trans_value from t(:totrans, :username), bindparams=[db.sa.bindparam('totrans', 'some text orig'), db.sa.bindparam('username', me.name)]) result

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread Michael Bayer
this appears to be an Elixir issue, check on their list. kportertx wrote: for some reason I cannot get my session to commit within a class Here is the error. Traceback (most recent call last): File /usr/local/lib/python2.6/dist-packages/cherrypy/ _cprequest.py, line 606, in respond

[sqlalchemy] Re: Netezza

2009-08-04 Thread Michael Bayer
dusans wrote: Is there a possibility to connect to Netezza db server? to use SQLalchemy with a certain backend, you have to answer these questions: 1. is it SQL ? 2. is there a python DBAPI available ? yes to both, then a new dialect module can be constructed that interfaces with this

[sqlalchemy] Re: Accessing attributes hidden by a join

2009-08-04 Thread Michael Bayer
Nathan Harmston wrote: Hi everyone, I am trying to get access to attributes which are hidden by a join: I have two tables intervals_table = Table(intervals, metadata, Column(interval_id, Integer, primary_key=True), Column(sentence_id,

[sqlalchemy] Re: MySQL DDL broken with autoincrement-column in multipart-key using InnoDB

2009-08-04 Thread Christian Schwanke
Hi Michael, thanks for your quick reply (again). I'm currently on the 0.6 branch after I ran into the first problem a few days ago but in my actual schema, the autogenerated ID in the second PK-column is referenced by another table that is mapped as a one-to-many relation. When persisting the

[sqlalchemy] Re: MySQL DDL broken with autoincrement-column in multipart-key using InnoDB

2009-08-04 Thread Michael Bayer
Christian Schwanke wrote: Hi Michael, thanks for your quick reply (again). I'm currently on the 0.6 branch after I ran into the first problem a few days ago but in my actual schema, the autogenerated ID in the second PK-column is referenced by another table that is mapped as a one-to-many

[sqlalchemy] Re: rev:6209 in sa06 breaks MSSQL on *nix

2009-08-04 Thread Ed Singleton
Thanks, all seems to be working fine now. Ed On 31 Jul 2009, at 15:48, Michael Bayer wrote: try r6225 Ed Singleton wrote: Revision 6209 in the sa06 branch breaks everything with MSSQL on Mac and Linux. It's not a major problem as I've reverted back. But I'd thought I'd let you know.

[sqlalchemy] Re: More SA, pyodbc, *nux and MSSQL problems

2009-08-04 Thread Ed Singleton
Thanks for this. I've been playing and learning more over the last few days. This is all AFAIK, but odbc.ini is the unixodbc/iodbc config and doesn't accept a charset. freetds.conf does accept a default client charset, but this shouldn't be necessary if you're using tds 8.0 as that

[sqlalchemy] Re: Firebird - called a stored procedure which returns a value

2009-08-04 Thread Werner F. Bruhin
Michael Bayer wrote: Werner F. Bruhin wrote: Figured out how to run the called procedure. sql = db.sa.text(select trans_value from t(:totrans, :username), bindparams=[db.sa.bindparam('totrans', 'some text orig'),

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread kportertx
I moved to elixir when declarative_base caused the exact same issue. Elixir still uses sqlalchemy's session so am I at least using the session correctly? Here is declarative_base code #!/usr/bin/env python # # #

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread Michael Bayer
kportertx wrote: I moved to elixir when declarative_base caused the exact same issue. Elixir still uses sqlalchemy's session so am I at least using the session correctly? thats unlikely. the error claims it is looking for a nonexistent table called __main__test, which is the kind of name

[sqlalchemy] Backref introspection

2009-08-04 Thread nail.xx
Hi all! I have following model classes: Entity = sqlalchemy.ext.declarative.declarative_base(name='Entity') class Ocean(Entity): __tablename__ = 'oceans' id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) name = sqlalchemy.Column(sqlalchemy.String(20), nullable=False)

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread kportertx
@ Michael Bayer, Sorry forgot to post the new error from the code without elixir, also there was a problem with the session.commit statement in that last post. It was supposed to be session.commit() not session.commit. Traceback (most recent call last): File

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread Michael Bayer
kportertx wrote: @ Michael Bayer, Sorry forgot to post the new error from the code without elixir, also there was a problem with the session.commit statement in that last post. It was supposed to be session.commit() not session.commit. ok so, you called create_all() after all modules

[sqlalchemy] Re: can I specifiy a postgres bigint using declarative_base?

2009-08-04 Thread sim
To answer my own question; I imported - from sqlalchemy.databases.postgres import PGBigInteger and then used that inplace of Integer in my column declarations. Apart from loosing Database agnosticism is there anything wrong with doing this? I tested inserting, querying and it all appeared

[sqlalchemy] Re: can I specifiy a postgres bigint using declarative_base?

2009-08-04 Thread Michael Bayer
On Aug 4, 2009, at 8:23 PM, sim wrote: To answer my own question; I imported - from sqlalchemy.databases.postgres import PGBigInteger and then used that inplace of Integer in my column declarations. Apart from loosing Database agnosticism is there anything wrong with doing this? I

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread kportertx
But this is all in one file, create_all() after all classes defining the model are loaded. I noticed earlier I accidentally posted the error twice, here is the source code. Could you try running this and see if you run into the same problem. Again this all one file. This is also my first week

[sqlalchemy] Re: Session will not commit within a class

2009-08-04 Thread kportertx
Could this have something to do with using a database in memory? I just noticed if I call create_all() within my class every time I want to update the database it works. Also it is able to add multiple items by pressing refresh. But when I browse away from the web page and return later it