[sqlalchemy] How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Esceo
Hi, all the followings are the code snippet from sqlalchemy import * meta = MetaData('sqlite://') parent = Table('parent', meta, Column('id', Integer, primary_key=True), Column('name', Integer) ) child = Table('child', meta, Column('id', Integer, primary_key=True),

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Esceo
Just wondering if this is a bug in _determine_fks i.e. 'child.id' probably should not be part of the foreign key pointing to parent On Nov 6, 7:42 pm, Esceo [EMAIL PROTECTED] wrote: Hi, all the followings are the code snippet from sqlalchemy import * meta = MetaData('sqlite://')

[sqlalchemy] mapper

2007-11-06 Thread lur ibargutxi
Hi everyone! I'm new in SQLAlchemy and this is my code: mappers['indicatorgroups'] = mapper(IndicatorGroups, tables['indicatorgroups']) mappers['groupgroups'] = mapper(GroupGroups, tables['groupgroups'], properties = { 'idindicatorgroupcontainer' :

[sqlalchemy] Re: mapper

2007-11-06 Thread Marco Mariani
lur ibargutxi wrote: 'idindicatorgroupcontainer' : relation(IndicatorGroups, primaryjoin=sql.and_(IndicatorGroups.idindicatorgroup==GroupGroups.idindicatorgroupcontainer)),'idindicatorgroupcontained' : relation(IndicatorGroups,

[sqlalchemy] Re: mapper

2007-11-06 Thread Marco Mariani
lur ibargutxi wrote: I forgot. Try using tables instead of classes that are not mapped yet.. mappers['groupgroups'] = mapper(GroupGroups, tables['groupgroups'], properties = { 'idindicatorgroupcontainer' : relation(IndicatorGroups,

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Esceo
the fix? was to add a check for self referential foreign keys in non- self-referential relations, and do not add those as part of the relation's foreign key collection, is this anywhere near the correct thing to do? # ignore self referential keys if not

[sqlalchemy] Re: mapper

2007-11-06 Thread lur ibargutxi
thanks a lot. That's the solution. 2007/11/6, Marco Mariani [EMAIL PROTECTED]: lur ibargutxi wrote: I forgot. Try using tables instead of classes that are not mapped yet.. mappers['groupgroups'] = mapper(GroupGroups, tables['groupgroups'],

[sqlalchemy] Can I have an integer primary keys that is not a sequence?

2007-11-06 Thread Christoph Zwerschke
If I define a table like that: Table('t', metadata, Column('c', Integer, primary_key=True)) then SQLAlchemy creates the column c as a SERIAL on PostgreSQL. Is there a way to tell SQLAlchemy to create an ordinary integer primary key, without any associated sequence? -- Chris

[sqlalchemy] Re: Can I have an integer primary keys that is not a sequence?

2007-11-06 Thread Paul Johnston
Hi, Is there a way to tell SQLAlchemy to create an ordinary integer primary key, without any associated sequence? Sure... autoincrement=False Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: Can I have an integer primary keys that is not a sequence?

2007-11-06 Thread Christoph Zwerschke
Paul Johnston wrote: Is there a way to tell SQLAlchemy to create an ordinary integer primary key, without any associated sequence? Sure... autoincrement=False Thanks a lot. Found it now in the API docs. I propose that this (and the fact that it is True by default) be also

[sqlalchemy] A Query object seems to be altered by a count() - is this a bug?

2007-11-06 Thread klaus
Hi all, when I try to build up a complicated query like this: query = session.query(Class) query = query.filter_by(...).add_entity(...).join(...) count = query.count() query = query.add_entity(...).join(...).order_by(...) print query.all() the last statement fails due to a broken SELECT. The

[sqlalchemy] bug with negative slices in orm.query.Query.__getitem__?

2007-11-06 Thread Simon Wittber
Slicing of Query instances can return inconsistent types if negative stop/start values are used. The below patch to tes/orm/query.py demonstrates the issue. When slices with negative stop/start values are used, a list type is returned. When positive values are used, a Query instance is returned.

[sqlalchemy] Re: A Query object seems to be altered by a count() - is this a bug?

2007-11-06 Thread klaus
Sorry, I was not finished yet. The outline is a follows: I want to join three relations unary o nullary o squared, where squared = binary^2, and find out which elements n are in relation n (unary o nullary o squared) fixed to some nullary element fixed. Here are the details: from sqlalchemy

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Michael Bayer
On Nov 6, 2007, at 7:03 AM, Esceo wrote: the fix? was to add a check for self referential foreign keys in non- self-referential relations, and do not add those as part of the relation's foreign key collection, is this anywhere near the correct thing to do? possibly. but id prefer not to

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Michael Bayer
the (child.c.current_id ==child.c.id) part of the parent relation is the culprit here, and also its nonsensical. the relation between parent and child is strictly based on the FK between those two tables. additionally its by definition a many-to-one relation; there is only one possible

[sqlalchemy] Wrong SQL statement for mapped select involving in_

2007-11-06 Thread klaus
Hi all, the following mapped select results in the wrong query. The problem seems to be related to the number of values in a list passed to in_ and maybe to holes in the list of chosen values. from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData(...)

[sqlalchemy] Re: access mapped object attributes

2007-11-06 Thread Christophe Alexandre
Hi, I am also interested in retrieving all the attributes resulting from the ORM. The loop on '.c' will list only the database columns. Is there a way to list the object attributes? Thanks a lot for your help, Chris -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL

[sqlalchemy] Re: access mapped object attributes

2007-11-06 Thread Rick Morrison
all of them? same as any Python object: obj_attributes = [k for k in obj.__dict__] On 11/6/07, Christophe Alexandre [EMAIL PROTECTED] wrote: Hi, I am also interested in retrieving all the attributes resulting from the ORM. The loop on '.c' will list only the database columns. Is there

[sqlalchemy] Re: access mapped object attributes

2007-11-06 Thread King Simon-NFHD78
You may be interested in an older thread, 'How to get list of relations': http://groups.google.com/group/sqlalchemy/browse_thread/thread/ff03af921 eb12acb/861597e8a72f5e6f Simon -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Christophe

[sqlalchemy] Re: mapper

2007-11-06 Thread lur ibargutxi
Once i did what you said, I'm trying to insert values to the db: indg=IndicatorGroups(idindicatorgroup=None, name=group) session.save(indg) session.flush() indsg=IndicatorGroups(idindicatorgroup=None, name=subgroup) session.save(indsg) session.flush() I create two IndicatorGroups but when I

[sqlalchemy] data inserted by db trigger is not returned when I re-query the row

2007-11-06 Thread Werner F. Bruhin
I insert a raw into a table and then retrieve again but columns which are filled by a db trigger don't return the updated values. The following is a code snippet and I wonder what I am missing. engine = sa.create_engine(url, encoding='utf8', echo=False) Session =

[sqlalchemy] Re: data inserted by db trigger is not returned when I re-query the row

2007-11-06 Thread Michael Bayer
On Nov 6, 2007, at 12:20 PM, Werner F. Bruhin wrote: I insert a raw into a table and then retrieve again but columns which are filled by a db trigger don't return the updated values. The following is a code snippet and I wonder what I am missing. engine = sa.create_engine(url,

[sqlalchemy] r3695 causes strange error

2007-11-06 Thread sdobrev
hi. i have somewhat messy setup (~test case), about association with intermediate table/class, double pointing to one side and single pointing to another. i do set up both A-links in one item; and set up only first in another item, the other link (a2_link) is pre-set to None. And, i have the

[sqlalchemy] Re: r3695 causes strange error

2007-11-06 Thread sdobrev
[EMAIL PROTECTED] wrote: sorry, here the files and the line 83 ( marked XXX ) there must be =None to get the error. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: Wrong SQL statement for mapped select involving in_

2007-11-06 Thread Michael Bayer
I cant reproduce this one. I see you have named bind params so I tried with postgres. it also works with sqlite. works with release 0.4.0 as well as the trunk.output is (with echoing): SELECT testView.id AS testView_id, testView.data AS testView_data FROM (SELECT test.id AS id,

[sqlalchemy] Re: bug with negative slices in orm.query.Query.__getitem__?

2007-11-06 Thread Michael Bayer
this is how its designed to work at the moment. if the slices are negative, it evaulates the query fully and returns the slice against the actual list. complicating matters more, we just had a feature request today to wrap the query in a subquery if additional criterion, such as order

[sqlalchemy] Re: r3695 causes strange error

2007-11-06 Thread Michael Bayer
ugh can you attach a zipfile please, they came out inline On Nov 6, 2007, at 5:46 PM, [EMAIL PROTECTED] wrote: sorry, here the files hi. i have somewhat messy setup (~test case), about association with intermediate table/class, double pointing to one side and single pointing to another.

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Michael Bayer
I also forgot to mention, the usual workaround here is just to specify foreign_keys on the relation() manually. so this works: pj = (child.c.parent_id == parent.c.id) (child.c.current_id ==child.c.id) mapper(Child, child, properties = { 'parent' : relation(Parent,

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Esceo
Thanks Micahel, What I intend to model is slightly out of convention here, The child model has a reference back to the parent, and at the same time a reference back to the current copy of itself. On the parent's end, it's only supposed to pick up the current copy, therefore the additional

[sqlalchemy] Re: A Query object seems to be altered by a count() - is this a bug?

2007-11-06 Thread Michael Bayer
indeed its extremely difficult to reproduce this one, and while it was pretty clear what caused it i found it impossible to work up a simpler set of tables that could create all the conditions necessary to produce an invalid query...in any case the offending code was some stuff that wasnt

[sqlalchemy] Re: r3695 causes strange error

2007-11-06 Thread Michael Bayer
nevermind, this one was pretty straightforward and r3695 didnt actually break things, it just revealed the lack of checking for things elsewhere, so works in r3747. On Nov 6, 2007, at 5:50 PM, [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: sorry, here the files and the line 83 (

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Michael Bayer
On Nov 6, 2007, at 8:24 PM, Esceo wrote: Thanks Micahel, What I intend to model is slightly out of convention here, The child model has a reference back to the parent, and at the same time a reference back to the current copy of itself. On the parent's end, it's only supposed to pick

[sqlalchemy] Re: How do we configure additional primary join constrains that seemingly involes other relations

2007-11-06 Thread Esceo
What I am slightly unsure about is how the viewonly flag affect the unit of work process. If i have acquired most_recent_child through parent, and made change to it, will they be saved as part of uow process? (guess I should just do a test) Lei On Nov 7, 12:43 pm, Michael Bayer [EMAIL

[sqlalchemy] How does auto-reconnect work?

2007-11-06 Thread Hong Yuan
Hi, In the release note of 0.3.7, the following is mentioned: - much improved auto-reconnect support But how can one configure this? I am using 0.3.10 with Postgresql. Very often, after some period of inactivity, the connection is closed and the whole application has to be closed and restarted

[sqlalchemy] Select entire column

2007-11-06 Thread JamesT
I am looking to filter specific columns in a table, but I cannot find how to do this. I can filter by setting these columns to a value, but not just grabbing the entire column. In SQL, I want to do this: SELECT artist FROM artist_table, where the only column kept is artist. The reason I want to

[sqlalchemy] Re: r3695 causes strange error

2007-11-06 Thread sdobrev
Michael Bayer wrote: nevermind, this one was pretty straightforward and r3695 didnt actually break things, it just revealed the lack of checking for things elsewhere, so works in r3747. yes, that works. but now multiple other things broke. pf - the mapper.properties in its new

[sqlalchemy] Re: mapper

2007-11-06 Thread lur ibargutxi
2007/11/6, lur ibargutxi [EMAIL PROTECTED]: Once i did what you said, I'm trying to insert values to the db: indg=IndicatorGroups(idindicatorgroup=None, name=group) session.save(indg) session.flush() indsg=IndicatorGroups(idindicatorgroup=None, name=subgroup) session.save(indsg)