[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread fleong
the foreign key between table2 and their children was wrong.. now works correctly. Thanks for your help! greetings, Fernando table_21 = \ Table( 'table_21', metadata, Column('id2', Integer, primary_key = True), Column('info', String), ForeignKeyConstraint(['id2'],['table_2.id2'

[sqlalchemy] Re: Getting str value when I want unicode

2009-05-18 Thread Michael Bayer
more recent versions of cx_oracle know how to return python unicode directly, if you are reading an NVARCHAR column. for VARCHAR, you have to also make sure the NLS_LANG environment variable is set to something like AMERICAN-AMERICA.UTF8 (or wahtevr nationality you are dealing with). On

[sqlalchemy] Re: Getting str value when I want unicode

2009-05-18 Thread zugnush
Yes, No I'm using oracle. I don't see anything applicable on the wikipage. I tried convert_unicode=True & assert_unicode=True but I now believe that both are more about conversion than giving hints on the native db coding. The column in question is varchar2 and the db version is 10.2.0.4.0 --

[sqlalchemy] Joined table inheritance mapping issues

2009-05-18 Thread Nathan Harmston
Hi, I am playing with the mapping inheritance structures to my database. I have a the following hierarchy: class Tag(object): pass class NormalisedNameTag(Tag): pass class NormalisedPlaceTag(Tag): pass The idea is that a pre-processing step will produce a series of tags and then

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 8:06 PM, Michael Bayer wrote: > > if you want to make a chained join like that, use just primaryjoin(), > dont use "secondary", and set viewonly=True. I might be off on the "dont use secondary" advice. if you do use "secondary", "secondary" is the "middle" table, so in t

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 8:02 PM, Nathan Harmston wrote: > > Hi, > > I am trying to map a relation in class which allows it to access > objects from a couple of tables away ie. > > class Zone(object): >pass > > class Sentence(object): > pass > > class RawTag(object): >pass > > class Process

[sqlalchemy] Accessing classes a table away in a mapper

2009-05-18 Thread Nathan Harmston
Hi, I am trying to map a relation in class which allows it to access objects from a couple of tables away ie. class Zone(object): pass class Sentence(object): pass class RawTag(object): pass class ProcessedTag(RawTag): pass mapper(RawTag, tag_table) mapper(Sentence, sentence_ta

[sqlalchemy] Re: Automatic eager loading

2009-05-18 Thread Michael Bayer
you'd have to roll that yourself. Its generally not feasable for every relation on an object to be eagerloaded since it would create too many joins. On May 18, 2009, at 11:11 AM, Joril wrote: > > Hi all, > is there a way to request at "query-time" eager loading on every > relation involved

[sqlalchemy] Re: Getting str value when I want unicode

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 6:17 PM, zugnush wrote: > > Thanks, I'm still getting a unicode decode error though. > > C:\Python26\lib\site-packages\sqlalchemy-0.5.2-py2.6.egg\sqlalchemy > \types.pyc in process(value) >468 def process(value): >469 if value is not None

[sqlalchemy] Re: Getting str value when I want unicode

2009-05-18 Thread zugnush
Thanks, I'm still getting a unicode decode error though. C:\Python26\lib\site-packages\sqlalchemy-0.5.2-py2.6.egg\sqlalchemy \types.pyc in process(value) 468 def process(value): 469 if value is not None and not isinstance(value, unicode): --> 470

[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread Michael Bayer
try taking a look at your SQL output. the issue is pretty obvious, the join condition between your two tables is insufficient to get a T22 row. table_2.id has two rows with "0" for the "id" column, so joining from table_2 to table_22 on just "id" gives you two rows. it has nothing to do

[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread fleong
0 in a numerical primary key.. excuse if it is obvious, but: what's wrong? :/ I've tried and nothing.. when ask for instances that are linked through 't22' get all instances of 'Table2'. There must be something in the relationships configuration involving the entire table.. can it be? On 18 may

[sqlalchemy] Re: Postgres not loading values into db

2009-05-18 Thread scrapbooker
On May 18, 12:42 pm, Michael Bayer wrote: > can you create a test case which reproduces ? Michael, yes, I'll create a test case which simplifies the issues. It's definitely not a Postgres issue, but rather how I'm managing the Session, dependencies, or the like. --~--~-~--~~-

[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread Michael Bayer
have you tried not using "0" for a primary key ? i feel like that might be getting in the way. On May 18, 2009, at 3:59 PM, fleong wrote: > > Sorry for the delay. Yes, i want to reference Table22, the 'correct' > code is as follows, but obtains the same result. Don't understand > because not

[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread fleong
Sorry for the delay. Yes, i want to reference Table22, the 'correct' code is as follows, but obtains the same result. Don't understand because not run when it corrects.. Is it not possible to link TableExt22 with Table22 only? Thanks for the quick answer! Fernando #--

[sqlalchemy] Re: SQLAlchemy 0.5.4p1 Released

2009-05-18 Thread az
hi i run today my tests just out of curiosity, so dont worry if not a time for it. here one more session.merge thing that has been working before... (now on trunk r5970) File "other/expression.py", line 436, in p = session.merge(p) File "sqlalchemy/orm/session.py", line 1162, in merge

[sqlalchemy] SQLAlchemy 0.5.4p1 Released

2009-05-18 Thread Michael Bayer
0.5.4 we hardly knew ye.A small glitch was introduced in 0.5.4 which broke the merge() feature, and incredibly we had no test coverage for the usage of merge() where some of the attributes on a newly minted object were left blank. This is a pretty strong blocker for anyone that uses m

[sqlalchemy] Re: Postgres not loading values into db

2009-05-18 Thread Michael Bayer
can you create a test case which reproduces ? On May 18, 2009, at 11:56 AM, scrapbooker wrote: > > Hello, > My code seems to operating fine, loading some values into a Postgres > 8.1 database using sqlalchemy 0.4.7 in Debian Lenny. The first 2 > tables load fine into Postgres, but on the third

[sqlalchemy] Re: Postgres not loading values into db

2009-05-18 Thread Eric Jahn
Looks like I get the exact same problem using sqlite, so my code is the culprit, not Postgres (surprise, surprise): 2009-05-18 12:04:53,885 INFO sqlalchemy.engine.base.Engine.0x..ac SELECT name FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type='table' OR

[sqlalchemy] Postgres not loading values into db

2009-05-18 Thread scrapbooker
Hello, My code seems to operating fine, loading some values into a Postgres 8.1 database using sqlalchemy 0.4.7 in Debian Lenny. The first 2 tables load fine into Postgres, but on the third looking at the logs (see below), something strange happens. sqlalchemy passes in the column values correct

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Michael Bayer
thanks, this is fixed in r5970 and I may release 0.5.4p1 today. On May 18, 2009, at 11:54 AM, Francesca Leon wrote: > Sorry, here it is: > > Traceback (most recent call last): > File "C:\dex\python\dex\tests\adrims\TestDataBase.py", line 973, > in testMerge_SomethingThatNeverExisted > se

[sqlalchemy] Re: Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 8:51 AM, fleong wrote: > t = Table1() > t.id = 0 > > tex = TableEx22() > tex.id = 0 > > s.add(t) > s.add(tex) > s.commit() > > t21 = Table21() > t21.id2 = 0 > t21.t1 = t > s.add(t21) > s.commit() > > t22 = Table22() > t22.id2 = 1 > t22.t1 = t > t22.tex = tex > s.add(t22) > s.

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Francesca Leon
Sorry, here it is: Traceback (most recent call last):   File "C:\dex\python\dex\tests\adrims\TestDataBase.py", line 973, in testMerge_SomethingThatNeverExisted     self.session.flush()   File "c:\python25\lib\site-packages\SQLAlchemy-0.5.4-py2.5.egg\sqlalchemy\orm\session.py", line 1354, in f

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 11:38 AM, Francesca Leon wrote: > May be I'm doing something weird... Anyway: I tried to "merge" on a > not existing object, like this: > > session.merge(myObject) > session.flush() # where "autoflush" is disabled on session > > The exception is triggered by the "flush" acti

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Francesca Leon
May be I'm doing something weird... Anyway: I tried to "merge" on a not existing object, like this: session.merge(myObject) session.flush() # where "autoflush" is disabled on session The exception is triggered by the "flush" action. "MyObject" is mapped on a table with some not nullable for

[sqlalchemy] Automatic eager loading

2009-05-18 Thread Joril
Hi all, is there a way to request at "query-time" eager loading on every relation involved? For example, given: - a class X that as a (normally lazy) relation to Y, which in turn has a (normally lazy) relation to Z - a query on class X is there a way to activate eager loading on every relation of

[sqlalchemy] SQLAlchemy as a FIFO buffer?

2009-05-18 Thread AF
Hello, I have several CGI and cron scripts and that I would like coordinate via a "First In / First Out" style buffer.That is, some processes are adding work units, and some take the oldest and start work on them. Since I need the queue to both survive system crashes and provide an audit rec

[sqlalchemy] Re: Getting str value when I want unicode

2009-05-18 Thread Michael Bayer
zugnush wrote: > > There seem to be a lot of people getting unicode when they want str. > > I want unicode, I've tried to force it with the connection > parameters. I get it for the column heading but not the value. > > Can anyone explain to me what I'm doing wrong. > > Thanks > Neil > > In [121]

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Michael Bayer
Francesca Leon wrote: > > Hi Michael > > I just downloaded version 0.5.4 of SqlAlchemy. > I would like to signal just a small detail that seems to make my tests > fail: > > [...] > File > "C:\Python25\lib\site-packages\sqlalchemy-0.5.4-py2.5.egg\sqlalchemy\orm\attributes.py", > line 379, in get >

[sqlalchemy] Getting str value when I want unicode

2009-05-18 Thread zugnush
There seem to be a lot of people getting unicode when they want str. I want unicode, I've tried to force it with the connection parameters. I get it for the column heading but not the value. Can anyone explain to me what I'm doing wrong. Thanks Neil In [121]: import sqlalchemy In [122]: engi

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Puzzle Stone
Great, cheers.Let's update SQLAlchemy to 0.5.4 for the performance enhancement. On Mon, May 18, 2009 at 9:20 AM, Michael Bayer wrote: > > Hello list - > > SQLAlchemy 0.5.4 is released, and this release is *highly* recommended > for all users.For an indication of how high, lets just say, highe

[sqlalchemy] Newbie anti hacker question.

2009-05-18 Thread Douglas E
I just started using SQL and SQLAlchemy 2 days ago. I don't know SQL or Alchemy very well yet but this is all the code I will ever need (at least for a while). This is my python code for the server. Have I done this well? What more could I do? What more can I do to make it hacker/cracker proof? I

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Francesca Leon
Hi Michael I just downloaded version 0.5.4 of SqlAlchemy. I would like to signal just a small detail that seems to make my tests fail: [...] File "C:\Python25\lib\site-packages\sqlalchemy-0.5.4-py2.5.egg\sqlalchemy\orm\attributes.py", line 379, in get return self.get(state, passive=passiv

[sqlalchemy] Inheritance problem: how to configure a relation with a child, but without the parent?

2009-05-18 Thread fleong
I am trying to configure the following relationships: table1 <-1---N-> table2 ___|___- type | | table_ex22 <1--N-> table21 table22 paste my code here. When relate a instance of Table22 with the Tabl

[sqlalchemy] Multiple self-referential relations

2009-05-18 Thread Wichert Akkerman
I am building a tree datastructure using parent pointers. The only differece from a standard adjancancy list is that I can have multiple trees, each identified by a root session node. In order to be allow fast queries each tree node has a pointer to the session id (ie the root node). Unfortunatel

[sqlalchemy] Re: SQLAlchemy 0.5.4 Released

2009-05-18 Thread Alexandre Conrad
Mike, Woooh ! it all sounds sounds great ! I was thinking that it would be nice to have an up-to-date version of your post you did a while back: http://techspot.zzzeek.org/?p=17 I know such a task takes time but it would be fun to see the results. That would keep SA's marketing in shape (even

[sqlalchemy] Re: Using column_property getting no results

2009-05-18 Thread Nathan Harmston
Yes that whats I meant. I was hoping to not have to create a class to do this, but its not going to be take long. I think was just reading more into what column_property could do. Thanks a lot, Nathan BTW SQLAlchemy is brilliant! 2009/5/18 Michael Bayer : > > > On May 17, 2009, at 2:13 PM, Nat