[sqlalchemy] Re: Beginner: query.join not cooperating

2008-06-25 Thread Kyle Schaffrick
On Tue, 24 Jun 2008 18:22:49 -0700 (PDT) bukzor [EMAIL PROTECTED] wrote: The Query.join() documentations says: def join(self, prop, id=None, aliased=False, from_joinpoint=False) 'prop' may be one of: * a class-mapped attribute, i.e. Houses.rooms What exactly counts as

[sqlalchemy] Re: Beginner: query.join not cooperating

2008-06-25 Thread bukzor
Thanks! That works, but is the line I quoted just wrong or outdated or what? This is what I'm talking about, under def join() http://www.sqlalchemy.org/docs/04/sqlalchemy_orm_query.html#docstrings_sqlalchemy.orm.query_Query By the way, is 0.4 the recommended version to use for a new project? On

[sqlalchemy] Re: Beginner: query.join not cooperating

2008-06-25 Thread Kyle Schaffrick
On Wed, 25 Jun 2008 00:23:41 -0700 (PDT) bukzor [EMAIL PROTECTED] wrote: Thanks! That works, but is the line I quoted just wrong or outdated or what? This is what I'm talking about, under def join()

[sqlalchemy] read only column with declaritive

2008-06-25 Thread Werner F. Bruhin
Michael had helped me in the past to get read only columns defined like this: ## old model non declarative ##class Quality(OrmObject): ##def comboname(self): ##return self._comboname ##comboname = property(comboname) ## ##quality = sao.mapper(Quality, quality_table, ##

[sqlalchemy] Exception when changing to declarative

2008-06-25 Thread Werner F. Bruhin
I am changing my model to using declarative. I am getting an exception bool' object has no attribute '__visit_name__' (full exception below) which was relatively difficult for me to trace down. The bool exception I get when I change this: vrecingrwfit = sao.relation('Vrecingrwfit',

[sqlalchemy] Re: read only column with declaritive - resolved

2008-06-25 Thread Werner F. Bruhin
It looks like I just confused myself, in my test case I got None returned and I thought it was a model definition issue but it was me leaving one of the columns used for the computed column at None. So if I do just the following the read only column (FB SQL computed column) are working for

[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread Werner F. Bruhin
Alex, alex bodnaru wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hello friends, as opposed to a table.query() that returns a list of records of that table, with fields accessible as record attributes, a select() statement returns a list of tuples with the values of the fields

[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread az
AFAIK non-orm queries yield RowProxies, which are sort of ordered dicts, i.e. can be used as sequences or as dicts, keyed by column-name or by column-object itself. class RowProxy(object): Proxy a single cursor row for a parent ResultProxy. Mostly follows ordered dictionary behavior,

[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thanks werner, but i was asking about a generic query (not about one table) alex Werner F. Bruhin wrote: | Alex, | | alex bodnaru wrote: | -BEGIN PGP SIGNED MESSAGE- | Hash: SHA1 | | | hello friends, | | as opposed to a table.query() that

[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thanks a lot, it realy works :) [EMAIL PROTECTED] wrote: | AFAIK non-orm queries yield RowProxies, which are sort of ordered | dicts, i.e. can be used as sequences or as dicts, keyed by | column-name or by column-object itself. | | class

[sqlalchemy] New istance in one-to-one relationship

2008-06-25 Thread [EMAIL PROTECTED]
Hi. I'm trying to insert new data into db using one-to-one relationship, but i'm getting this error: sqlalchemy.exceptions.OperationalError: (OperationalError) (1048, Column 'address_id' cannot be null) u'INSERT INTO companies (address_id, company, ico, dic, bank_account) VALUES (%s, %s, %s, %s,

[sqlalchemy] Re: Beginner: printing out queries

2008-06-25 Thread Michael Bayer
On Jun 24, 2008, at 9:27 PM, bukzor wrote: Is there a way to print out the query as it would execute on the server? I'd like to copy/paste it into the server to get the 'explain' output, and the '%s' variables are very unhelpful here. the string output of str(statement) is what's actually

[sqlalchemy] Re: New istance in one-to-one relationship

2008-06-25 Thread az
maybe try uselist=True in both relation and backref ?? just guessing On Wednesday 25 June 2008 11:36:02 [EMAIL PROTECTED] wrote: Hi. I'm trying to insert new data into db using one-to-one relationship, but i'm getting this error: sqlalchemy.exceptions.OperationalError: (OperationalError)

[sqlalchemy] Re: New istance in one-to-one relationship

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 4:36 AM, [EMAIL PROTECTED] wrote: Hi. I'm trying to insert new data into db using one-to-one relationship, but i'm getting this error: sqlalchemy.exceptions.OperationalError: (OperationalError) (1048, Column 'address_id' cannot be null) u'INSERT INTO companies

[sqlalchemy] Mapped class and c attribute in 0.5

2008-06-25 Thread Huy Do
Hi, I read in the 0.5 release notes that the c attribute was no longer necessary when doing queries using the mapped class, but I did not see it mentioned that the c attribute was removed all together. It's just that I've been using the c attribute in my Mapped classes to access the

[sqlalchemy] Re: Mapped class and c attribute in 0.5

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 10:48 AM, Huy Do wrote: Hi, I read in the 0.5 release notes that the c attribute was no longer necessary when doing queries using the mapped class, but I did not see it mentioned that the c attribute was removed all together. It's just that I've been using the c

[sqlalchemy] Divide columns with possible zeroDivisionError

2008-06-25 Thread Dominique
Hello, A beginner question: I have a table with 4 columns: id, colA, colB, colC. I want to order (and make other operations as well ) the table asc or desc using the result of colB / colC knowing that colB and colC may equal to 0. When I try using query, the returned results are not correctly

[sqlalchemy] validation and old values

2008-06-25 Thread sandro dentella
Hi, I'm adding validation to a (generic) gtk sql editor. The first thing I'd like to know is if I can reach the old values of an instance after I modified it (before committing). The reason is that I'd like to give the possibility to have new and old values in the validation of

[sqlalchemy] Re: Beginner: query.join not cooperating

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 1:24 PM, bukzor wrote: Thanks for that versioning overview. Sorry for changing the topic (Should I make a separate post?), but is there a way to make the joins more automatic? I'd like to just specify some filter against table A and another against table B and have

[sqlalchemy] Re: validation and old values

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 1:45 PM, sandro dentella wrote: Hi, I'm adding validation to a (generic) gtk sql editor. The first thing I'd like to know is if I can reach the old values of an instance after I modified it (before committing). The reason is that I'd like to give the

[sqlalchemy] Re: Beginner: printing out queries

2008-06-25 Thread bukzor
Thanks. Trying to do this in 0.5, it seems someone deleted the Query.compile() method without updating the rest of the code: Traceback (most recent call last): File ./test1.py, line 139, in ? try: exit(main(*argv)) File ./test1.py, line 121, in main print_query(q) File ./test1.py,

[sqlalchemy] Re: Divide columns with possible zeroDivisionError

2008-06-25 Thread az
it was suggested by someone last week, for ordering dates that can be null, to use something like order_by( start_date is not null, start_date, end_date is null, end_date), i.e. use extra prefixing/suffixing boolean expressions to subcategorize the actual values. so depending on where do u

[sqlalchemy] Re: Beginner: printing out queries

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 2:14 PM, bukzor wrote: Thanks. Trying to do this in 0.5, it seems someone deleted the Query.compile() method without updating the rest of the code: Traceback (most recent call last): File ./test1.py, line 139, in ? try: exit(main(*argv)) File ./test1.py, line

[sqlalchemy] Re: overzealous check breaks doctesting

2008-06-25 Thread Martijn Faassen
jason kirtland wrote: [snip] Could the check somehow be modified to still find true builtins but not those defined in a doctest? Sure. Any suggestions for an alternate check? Heh, no. It's quite difficult to come up with any alternative.. I wonder why doctest.DocFileSuite makes these

[sqlalchemy] Re: overzealous check breaks doctesting

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 2:35 PM, Martijn Faassen wrote: jason kirtland wrote: [snip] Could the check somehow be modified to still find true builtins but not those defined in a doctest? Sure. Any suggestions for an alternate check? Heh, no. It's quite difficult to come up with any

[sqlalchemy] Re: overzealous check breaks doctesting

2008-06-25 Thread jason kirtland
Martijn Faassen wrote: jason kirtland wrote: [snip] Could the check somehow be modified to still find true builtins but not those defined in a doctest? Sure. Any suggestions for an alternate check? Heh, no. It's quite difficult to come up with any alternative.. I wonder why

[sqlalchemy] Re: overzealous check breaks doctesting

2008-06-25 Thread Martijn Faassen
jason kirtland wrote: Martijn Faassen wrote: jason kirtland wrote: [snip] Could the check somehow be modified to still find true builtins but not those defined in a doctest? Sure. Any suggestions for an alternate check? Heh, no. It's quite difficult to come up with any alternative.. I

[sqlalchemy] sharding id_chooser query_chooser

2008-06-25 Thread lilo
I am trying to understand what id_chooser and query_chooser do. Id_chooser basically uses a instance primary key to determine what shard the intance should be saved to? My primary keys(globally unique) are made of up more than one fields. Would that be a problem with Id_chooser? How/when would

[sqlalchemy] Re: Mapped class and c attribute in 0.5

2008-06-25 Thread Huy Do
Michael Bayer wrote: On Jun 25, 2008, at 10:48 AM, Huy Do wrote: Hi, I read in the 0.5 release notes that the c attribute was no longer necessary when doing queries using the mapped class, but I did not see it mentioned that the c attribute was removed all together. It's just that

[sqlalchemy] Re: Adding a filter_by() clause by default.

2008-06-25 Thread Huy Do
Michael Bayer wrote: using 0.5: from sqlalchemy.orm import Query, sessionmaker class MyQuery(Query): def __new__(cls, entities, **kwargs): if hasattr(entities[0], 'deleted_at'): return Query(entities, **kwargs).filter_by(deleted_at=None) else:

[sqlalchemy] Re: sharding id_chooser query_chooser

2008-06-25 Thread Michael Bayer
On Jun 25, 2008, at 6:30 PM, lilo wrote: I am trying to understand what id_chooser and query_chooser do. Id_chooser basically uses a instance primary key to determine what shard the intance should be saved to? id_chooser receives a primary key identifier, and then returns a list of