[sqlalchemy] relation does not honor order_by attribute

2009-10-14 Thread robert rottermann
hi there, I am using a one to many relation, and would like the result to be ordered by a field of the child table. however no order by statement is executed when I access the related property of the parent object. this is my declaration: mitarbeiter_table = Table('mitarbeiter',

[sqlalchemy] Re: relation does not honor order_by attribute

2009-10-14 Thread Gaetan de Menten
On Wed, Oct 14, 2009 at 08:34, robert rottermann rob...@redcor.ch wrote: I am using a one to many relation, and would like the result to be ordered by a field of the child table. however no order by statement is executed when I access the related property of the parent object. this is my

[sqlalchemy] Re: relation does not honor order_by attribute

2009-10-14 Thread robert rottermann
thanks robert Gaetan de Menten schrieb: On Wed, Oct 14, 2009 at 08:34, robert rottermann rob...@redcor.ch wrote: I am using a one to many relation, and would like the result to be ordered by a field of the child table. however no order by statement is executed when I access the related

[sqlalchemy] Re: problem with like

2009-10-14 Thread Christian Démolis
Thx Kyle and Conor, i finally dit that s = session.query(Contact.IdContact, Contact.Civilite, Contact.Nom, Contact.Prenom, ContactTel.Tel).filter(ContactTel.IdContact==Contact.IdContact).filter(Contact.IdDossier==self.dossierPourChargement.IdDossier) # s =

[sqlalchemy] How to implement View

2009-10-14 Thread reetesh nigam
Hi All, I want to implemet View in my project. I am using sqlalchemy 0.4.4, turbogears1.0.4b3, python 2.5 Thanks Reetesh Nigam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

[sqlalchemy] Create Table errors on mysql...

2009-10-14 Thread Martijn Moeling
Hi, I have a python module where I am implementing several classes. When I do a metadata.create_all(engine) every time Mysql trows an exception (1064, PROGRAMMING ERROR), but on a different table, I think SQLAlchemy is behaving different every time I run the program. ie (one of the

[sqlalchemy] Re: Very odd utf8 problem

2009-10-14 Thread Yo'av Moshe
Hey, thanks. I tried to add the encoding parameter with the latin1 value, but it messed up everything and all of content was shown wrong. I decided to try to convert my whole DB into UTF-8, but I found out that I'm not sure how SA converts the gibberish in my DB into Hebrew. After a lot of trying

[sqlalchemy] Re: Create Table errors on mysql...

2009-10-14 Thread Conor
Martijn Moeling wrote: Hi, I have a python module where I am implementing several classes. When I do a metadata.create_all(engine) every time Mysql trows an exception (1064, PROGRAMMING ERROR), but on a different table, I think SQLAlchemy is behaving different every time I run the

[sqlalchemy] What happens if a session is closed inside a subtransaction?

2009-10-14 Thread Oliver Beattie
Hi All, I'm just wondering what happens if I were to call session.close() whilst inside a subtransaction? Would it indeed close the session and abort all of the parent transactions or would it do nothing? Looking at the code (and I haven't looked at it in any great detail, sorry) I imagine that

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread Michael Bayer
David Gardner wrote: I have a PostgreSQL function that returns a composite type (a text field and 6 bigint columns). Currently I am calling it with: session.query(Job,func.farm.call_job_status(Job.path)).filter(Job.path=='testshow').first() Which returns a tuple, but the second element is

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread Michael Bayer
mviamari wrote: Hello, I'm writing tests for my database, and I've run into a little bit of confusion. Say I have a class (we'll call it person) with two declared attributes that correspond to db columns: person.id person.name If I randomly assign a person object another attribute

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Michael Bayer
Luke Arno wrote: I have a MSSQL server with two logical databases. (I inherited this situation, of course.) There is a table in each database and an association table in one of them. What is the right way to configure this? Here is what I have and it complains about the values in

[sqlalchemy] Re: Create Table errors on mysql...

2009-10-14 Thread Martijn Moeling
Thanks Guy's! Kinda stupid, but that happens with the use of examples. Martijn On Oct 14, 2009, at 3:34 PM, limodou wrote: On Wed, Oct 14, 2009 at 9:03 PM, Martijn Moeling mart...@xs4us.nu wrote: Hi, I have a python module where I am implementing several classes. When I do a

[sqlalchemy] Re: What happens if a session is closed inside a subtransaction?

2009-10-14 Thread Michael Bayer
Oliver Beattie wrote: Hi All, I'm just wondering what happens if I were to call session.close() whilst inside a subtransaction? Would it indeed close the session and abort all of the parent transactions or would it do nothing? Looking at the code (and I haven't looked at it in any great

[sqlalchemy] Re: Modifying the scopefunc of an existing ScopedSession

2009-10-14 Thread Gaetan de Menten
On Tue, Oct 13, 2009 at 16:49, Michael Bayer mike...@zzzcomputing.com wrote: We have a situation where we have an existing ScopedSession, but want to change its scopefunc.  This sounds like a strange requirement, it is because we use elixir - the issue is discusses here:

[sqlalchemy] Re: Modifying the scopefunc of an existing ScopedSession

2009-10-14 Thread Gaetan de Menten
On Wed, Oct 14, 2009 at 17:09, Gaetan de Menten gdemen...@gmail.com wrote: Btw: Iwan, did you try: factory = elixir.session.session_factory elixir.session.registry = sqlalchemy.util.ScopedRegistry(maker, scope_func=your_scope_func) Of course, that should read : factory =

[sqlalchemy] Can I use MapperExtension.before_insert to prevent an object from being INSERTed on commit()?

2009-10-14 Thread bojanb
I was under the impression that returning EXT_STOP in my MapperExtension.before_insert() can prevent an object from being inserted into the database altogether, but that doesn't seem to be working, so I'm not sure if I'm misunderstanding the operation of MapperExtensions or it's a bug. I'd like

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Luke Arno Sent: 14 October 2009 16:41 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: ORM Many to Many Across Two Databases It looks like if I put the relation on the

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread David Gardner
I have a composite type that I defined as: CREATE TYPE farm.job_status_ret AS (total bigint, valid bigint, invalid bigint, processing bigint, pending bigint, canceled bigint); I dropped the text field. When I run the query in postgres I get the six distinct fields:

[sqlalchemy] Re: Can I use MapperExtension.before_insert to prevent an object from being INSERTed on commit()?

2009-10-14 Thread Michael Bayer
bojanb wrote: I was under the impression that returning EXT_STOP in my MapperExtension.before_insert() can prevent an object from being inserted into the database altogether, but that doesn't seem to be working, so I'm not sure if I'm misunderstanding the operation of MapperExtensions or

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread Michael Bayer
David Gardner wrote: I have a composite type that I defined as: CREATE TYPE farm.job_status_ret AS (total bigint, valid bigint, invalid bigint, processing bigint, pending bigint, canceled bigint); I dropped the text field. When I run the query in postgres I get

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Luke Arno
Thanks, Simon. Good suggestion, but these are databases and not schema within a database. If I use the schema=MyDatabase. ( notice the .) and quote_schema=False, the table names come out like I want, but look at what happens to the label here: SELECT [LeftTable_1].description AS

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread David Gardner
Did a quick test using psycopg2 and it returns a tuple of six longs: (9892718L, 1046L, 189L, 235L, 9890143L, 1105L) --- import psycopg2 import psycopg2.extensions DB_HOST = 'localhost' DB_NAME = 'hdpsdb' DB_USER = 'testuser' DB_PASS = 'testuser' db_uri = dbname='%s'

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Luke Arno
So, is there any chance that relations across multiple _logical_ databases on a _single_ physical server will be supported by SQLAlchemy in the future? As I mentioned before, this could work (at least for MSSQL) if we only had a databasename=foo on Table(). I am not really sure how much work it

[sqlalchemy] Re: Can I use MapperExtension.before_insert to prevent an object from being INSERTed on commit()?

2009-10-14 Thread bojanb
it does not. http://www.sqlalchemy.org/docs/05/reference/orm/interfaces.html?highl... Returning EXT_STOP will halt processing of further extensions handling that method. that only refers to additional extensions. Right. The doc was a little ambigous - the or use the default functionality

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Michael Bayer
Luke Arno wrote: So, is there any chance that relations across multiple _logical_ databases on a _single_ physical server will be supported by SQLAlchemy in the future? that is supported now, via the schema argument to Table, assuming you are connecting with an account that has access to all

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
So if I read the documentation right, it appears that because I'm accessing the object via the primary key, it looks the object up locally (i.e. in the session) and returns that object. Other than doing a query/lookup on another attribute, how can I force it to create the object from the data in

[sqlalchemy] MySQL Stored Procedures and result sets

2009-10-14 Thread BEES INC
Hi I have a stored procedure on a mysql server i'm calling. However, all i can seem to get back are the arguments passed to the procedure if i do it using MySQLdb i just use the cursor .nextset() to get the actual results of the procedure call Is there a way I can advance the record set to

[sqlalchemy] Re: MySQL Stored Procedures and result sets

2009-10-14 Thread Michael Bayer
On Oct 14, 2009, at 8:40 PM, BEES INC wrote: Hi I have a stored procedure on a mysql server i'm calling. However, all i can seem to get back are the arguments passed to the procedure if i do it using MySQLdb i just use the cursor .nextset() to get the actual results of the procedure

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
Michael, First, Thanks for your help. Second, something still isn't right. Here's the code in question: obj = Obj() org = Org() self.assertNotEqual(obj, None) self.assertNotEqual(org, None) #Nonsense_var is not representative of a table column,

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
UPDATE: If I inject a session.expunge_all() before I query the DB for the objects again, the undeclared attribute is no longer present (i.e. I get the AttributeError I expect). On Oct 14, 7:08 pm, mviamari mviam...@gmail.com wrote: Michael, First, Thanks for your help. Second, something

[sqlalchemy] a special relation

2009-10-14 Thread rajasekhar911
I have a special kind of relation. Relation = Table(relations, metadata, Column('src_id',Unicode(50)), Column('dest_id',Unicode(50)), Column('relation',Unicode(50)) ) class Node(DeclarativeBase): __tablename__ = 'nodes' name = Column(Unicode(50), nullable=False)