[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread Eric Ongerth
Thanks for the ideas. I thought of all of the above. The one I've been using is the accessor which unions together the necessary things. My question came up when I wondered if there was some even more fundamental way to handle these forwards-backwards cases. I'm glad to know I'm already doing

[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread az
there is... u do not want to know if A points B or B points A, u want to know if A and B are related in whatever aspect. That is, A and B are members of some set X denoting that aspect. i.e. moving the belonginess out of A and B alltogether. but this isn't going to make your DB simpler...

[sqlalchemy] Re: returning primary key of object without know what it is called.

2008-12-05 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Faheem Mitha Sent: 04 December 2008 20:43 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] returning primary key of object without know what it is called. Hi, I'm trying to

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Eduardo Schettino
Hi, There are some sphinx system messages on: http://www.sqlalchemy.org/docs/sphinxtest/intro.html Reference Documentation¶ * System Message: WARNING/2 (/home/classic/dev/sphinx/doc/build/intro.rst) undefined label: datamapping – if you don't give a link caption

[sqlalchemy] any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread az
i'm asking about SA-related stuff, i know how to handle the python side. how to lock relations, collections etc - how to make an instance readonly? and eventualy if it is poosible after that to unlock that instance at some point - so lock all the user-visible stuff but leave some flag

[sqlalchemy] Re: returning primary key of object without know what it is called.

2008-12-05 Thread Faheem Mitha
On Fri, 5 Dec 2008, King Simon-NFHD78 wrote: You can get the mapper for a given instance using the sqlalchemy.orm.object_mapper function, and that mapper has a 'primary_key_from_instance' method. A generic primary_key function might look like this (untested): import sqlalchemy.orm as orm

[sqlalchemy] Cascading deletes to children

2008-12-05 Thread James Brady
Hi all,I'm trying to get deletes and updates cascaded down from a parent object to the child objects (connected by ForeignKey). It all seems pretty simple in the docs, but I can't get it to work! I'm using MySQL with the InnoDB engine, and have played with all the variation of the onupdate,

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Jon Nelson
The searching is a bit weird. If I search for Adjacency I get no results. If I search for adjacency (all lower case) I get results, the first of which has an upper-cased Adjacency. Otherwise they look nice and I'm sure will look nicer-yet as time goes on! -- Jon

[sqlalchemy] Re: any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread Michael Bayer
On Dec 5, 2008, at 11:10 AM, [EMAIL PROTECTED] wrote: i'm asking about SA-related stuff, i know how to handle the python side. how to lock relations, collections etc - how to make an instance readonly? and eventualy if it is poosible after that to unlock that instance at some point - so

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Michael Bayer
well we have no control over any of thatI don't know that Sphinx search uses case insensitivity for full text searches. On Dec 5, 2008, at 11:53 AM, Jon Nelson wrote: The searching is a bit weird. If I search for Adjacency I get no results. If I search for adjacency (all lower case)

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread Michael Bayer
use the passive_updates=True, passive_deletes='all' flags. These are described at http://www.sqlalchemy.org/docs/05/sqlalchemy_orm.html#docstrings_sqlalchemy.orm_modfunc_relation . On Dec 5, 2008, at 11:42 AM, James Brady wrote: Hi all, I'm trying to get deletes and updates cascaded

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread Michael Bayer
actually, use passive_deletes=True, not 'all'. It will issue DELETEs only for collections that are already loaded, this doesn't break anything and prevents unnecessary SELECTs of unloaded collections. The True setting is needed so that the session can update the state of those

[sqlalchemy] Re: any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread Andreas Jung
On 05.12.2008 17:10 Uhr, [EMAIL PROTECTED] wrote: i'm asking about SA-related stuff, i know how to handle the python side. how to lock relations, collections etc - how to make an instance readonly? and eventualy if it is poosible after that to unlock that instance at some point - so lock all

[sqlalchemy] Re: any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread az
On Friday 05 December 2008 19:22, Michael Bayer wrote: On Dec 5, 2008, at 11:10 AM, [EMAIL PROTECTED] wrote: i'm asking about SA-related stuff, i know how to handle the python side. how to lock relations, collections etc - how to make an instance readonly? and eventualy if it is

[sqlalchemy] Re: any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread az
ah yes, i forgot that already have that in dbcook! but i dont think it will avoid adding things to collections. okay thanks i'll dig further. On Friday 05 December 2008 19:39, Andreas Jung wrote: On 05.12.2008 17:10 Uhr, [EMAIL PROTECTED] wrote: i'm asking about SA-related stuff, i know

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread James
Ah, I should say I'm using SA 0.4.3 - I going to try the same test on 0.5 On Dec 5, 11:36 am, Michael Bayer [EMAIL PROTECTED] wrote: actually, use passive_deletes=True, not 'all'.   It will issue DELETEs   only for collections that are already loaded, this doesn't break   anything and

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread Michael Bayer
Assuming user_id is a surrogate primary key, I dont see any need for onupdate=CASCADE to be used here. Additionally, ondelete=CASCADE on your hat.user_id column implies that hat will be deleted when a user entry is deleted - however your relation has this set up on the many-to-one side

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread James
Yep, the same behaviour in 0.5rc4 On Dec 5, 12:44 pm, James [EMAIL PROTECTED] wrote: Ah, I should say I'm using SA 0.4.3 - I going to try the same test on 0.5 On Dec 5, 11:36 am, Michael Bayer [EMAIL PROTECTED] wrote: actually, use passive_deletes=True, not 'all'.   It will issue DELETEs  

[sqlalchemy] Re: Cascading deletes to children

2008-12-05 Thread James
Ah! I see - I had the cascade and passive_delete arguments in the wrong place. This works as expected in 0.4.3 and 0.5 now. Thanks for the help James On Dec 5, 12:47 pm, Michael Bayer [EMAIL PROTECTED] wrote: Assuming user_id is a surrogate primary key, I dont see any need for  

[sqlalchemy] objects created using sqlalchemy

2008-12-05 Thread Faheem Mitha
Hi, I'm using sqla with the following schema (see below). I'm creating a cell object implicitly, using the function make_cell and the association proxy pattern. def make_cell(patient_obj, snp_obj, snpval): patient_obj.snps[snp_obj] = snpval return patient_obj My question is, is

[sqlalchemy] Re: objects created using sqlalchemy

2008-12-05 Thread Michael Bayer
On Dec 5, 2008, at 3:01 PM, Faheem Mitha wrote: Hi, I'm using sqla with the following schema (see below). I'm creating a cell object implicitly, using the function make_cell and the association proxy pattern. def make_cell(patient_obj, snp_obj, snpval):

[sqlalchemy] MySQL, unions and ordering

2008-12-05 Thread Bo Shi
Hi all, There appear to be some nuances to using order by statements with set operations like unions in MySQL but the following is allowed*: (SELECT a,b from DBA.tbl ORDER BY b LIMIT 5) UNION ALL (SELECT a,b from DBB.tbl ORDER BY b LIMIT 5) ORDER BY b When I attempt to generate such a

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Michael Bayer
try calling self_group() on each select object. On Dec 5, 2008, at 3:55 PM, Bo Shi wrote: Hi all, There appear to be some nuances to using order by statements with set operations like unions in MySQL but the following is allowed*: (SELECT a,b from DBA.tbl ORDER BY b LIMIT 5) UNION ALL

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Bo Shi
Thanks for the quick response! The following does *not* work. Am I making the call incorrectly? sel = union_all(*[q.self_group() for q in querylist]) On Fri, Dec 5, 2008 at 4:08 PM, Michael Bayer [EMAIL PROTECTED] wrote: try calling self_group() on each select object. On Dec 5, 2008,

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Michael Bayer
that's correct. what does it render ? On Dec 5, 2008, at 4:17 PM, Bo Shi wrote: Thanks for the quick response! The following does *not* work. Am I making the call incorrectly? sel = union_all(*[q.self_group() for q in querylist]) On Fri, Dec 5, 2008 at 4:08 PM, Michael Bayer [EMAIL

[sqlalchemy] utf hex instead of utf-8 return

2008-12-05 Thread n00b
greetings, SA (0.5.0rc1) keeps returning utf hex in stead of utf-8 and in the process driving me batty. all the mysql setup is fine, the chars look good and are umlauting to goethe's delight. moreover, insert and select are working perfectly with the MySQLdb api on three different *nix systems,

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Michael Bayer
from sqlalchemy import * s = select([x, y]).select_from(table) print union_all(s.self_group(), s.self_group()).order_by(foo) (SELECT x, y FROM table) UNION ALL (SELECT x, y FROM table) ORDER BY foo On Dec 5, 2008, at 4:17 PM, Bo Shi wrote: Thanks for the quick response! The

[sqlalchemy] Re: utf hex instead of utf-8 return

2008-12-05 Thread Michael Bayer
I'm not sure of the mechanics of what you're experiencing, but make sure you use charset=utf8use_unicode=0 with MySQL. On Dec 5, 2008, at 4:17 PM, n00b wrote: greetings, SA (0.5.0rc1) keeps returning utf hex in stead of utf-8 and in the process driving me batty. all the mysql setup is

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Bo Shi
I had to upgrade to 0.4.7 from 0.4.2, but your sample query works, however, my application of it does not. Sorry I'm being so light on details, I'll try to reproduce with a complete sample versus using snippets of production code. Each select statement is generated like so: sel =

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Michael Bayer
there's logic which is removing the order_by's from the selects, and in that case this is what's blowing away the parenthesis as well. Some databases don't even allow ORDER BY inside of the queries used in a UNION since in the absense of LIMIT/OFFSET, which also is not standard SQL,

[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread Eric Ongerth
Oh, right. I don't know what type of brain fog obscured that basic relational fact, except that I may have been burning my synapses a bit too hot lately resulting in a deplorable deficit of neurotransmitters. Thank you for helping me regain the sight of the obvious. On Dec 5, 1:16 am, [EMAIL

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-05 Thread Bo Shi
Thanks; the monkeypatch approach works nicely. Using the alias() method will raise AttributeError: 'Alias' object has no attribute '_order_by_clause' On Fri, Dec 5, 2008 at 7:25 PM, Michael Bayer [EMAIL PROTECTED] wrote: there's logic which is removing the order_by's from the selects,

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Eric Ongerth
Mike, Gaetan's right -- I just viewed the site a day after you (Mike) said that the li issue had been fixed, but they're still too widely spaced for sure. There are several conflicting (well ok, inheriting/ overriding) settings of line-height across the various css files, and it does not appear

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Eric Ongerth
Forgot to add that I can't see much reason for links to be given a line-height that would be any different from the text that surrounds them -- at least not on the TOC page. That's why I felt free to scrap the 'a' rule and put the 'li li' in the same spot. If the 'a' rule is necessary for other

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-05 Thread Eric Ongerth
Oh yeah, and in Main Documentation (at least) you have some ul class=simple lists nested inside of blockquote elements, which is resulting in some of your lists being much farther indented than others, without a good visual reason why. Seems like the difference could be eliminated. I sent new