[sqlalchemy] Re: Extending sqlalchemy.schema.Column and metaprogramming traps

2008-12-11 Thread Angri
Here it is: http://www.sqlalchemy.org/trac/ticket/1244 Maybe it is good idea to drop some new lines in faq? Something like this: Q: How should I extend sqlalchemy.schema.Column? A: You surely dont need it. Recommended way to achive your possible needs is to write instance-factory function which

[sqlalchemy] Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread Andreas Jung
Can the decl. layer be used to setup a self-referential mapper like class Foo(Base): __tablename__ = 'foo' __table_args__ = {'autoload' : True} children = relation(Foo, primaryjoin=Foo.parent_id==Foo.id) parent = relation(Foo, primary_join=Foo.parent_id=Foo.id,

[sqlalchemy] Re: Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread az
afaik, u can supply strings instead of real things everywhere in those arguments.. they are eval()ed against some context at later time. On Thursday 11 December 2008 10:40, Andreas Jung wrote: Can the decl. layer be used to setup a self-referential mapper like class Foo(Base):

[sqlalchemy] Re: Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread Andreas Jung
On 11.12.2008 11:10 Uhr, [EMAIL PROTECTED] wrote: afaik, u can supply strings instead of real things everywhere in those arguments.. they are eval()ed against some context at later time. This works to some degree: class Hierarchies(Base): __tablename__ = 'hierarchies' __table_args__

[sqlalchemy] Re: PickleType copy_values and compare_values bug

2008-12-11 Thread Jonathan Marshall
On Dec 10, 7:33 pm, Michael Bayer [EMAIL PROTECTED] wrote: this is the documented behavior and the comparator=operator.eq setting   is provided for exactly the purpose of efficiently comparing objects   which do implement an __eq__() that compares internal state, like that   of a dict (and

[sqlalchemy] Create tables with metadata

2008-12-11 Thread jarrod.ches...@gmail.com
Hi I've scoured the documentation and i can't find any info on how to create a column using metadata. from sqlalchemy import engine from sqlalchemy import schema from sqlalchemy import types _config_dbengine = engine.create_engine('sqlite:tmp/db') _config_metadata =

[sqlalchemy] .compile() not using default params

2008-12-11 Thread zepolen
It seems compile()'ing a query results in the default bindparams not being used, is this a bug? Simple test case: from sqlalchemy import * engine = create_engine('postgres://uname:[EMAIL PROTECTED]/testdb') query = text('select * from table limit :num', bindparams=[bindparam('num',

[sqlalchemy] Re: Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 5:50 AM, Andreas Jung wrote: This works to some degree: class Hierarchies(Base): __tablename__ = 'hierarchies' __table_args__ = ( { 'autoload' : True, }) parent_id = Column('parent_id', Integer, ForeignKey('hierarchies.id')) _children =

[sqlalchemy] Re: PickleType copy_values and compare_values bug

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 5:50 AM, Jonathan Marshall wrote: The problem seems to be the assumption that copies of an object produce identical pickles. Perhaps a better solution may be for compare_values to use __eq__ by default if it exists otherwise compare __dict__? comparing __dict__ is

[sqlalchemy] Re: save on new objects?

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 9:43 AM, Max Ischenko wrote: Hello, I'm migrating my pylons app to SA 0.5 I ran into strange behaviour. I found that hen creating new object it ends up in Session automatically. Why is that? After some debugging I found this: def init_instance(self, mapper,

[sqlalchemy] Re: .compile() not using default params

2008-12-11 Thread Michael Bayer
you're compiling the text() construct against the DefaultDialect, when it needs to be compiled against the PG dialect in order for the :num bind param to be converted to PG's desired format, %(num)s.Also im not 100% sure if PG allows bind params for LIMIT, probably does though. On Dec

[sqlalchemy] Re: date in sqlite

2008-12-11 Thread Michael Bayer
the name of your Date column is premiera, I dont see a termin column specified in the example ? On Dec 11, 2008, at 7:35 AM, grat wrote: Hi, i have this table: class ZmenaDH(Base): __tablename__=zmenahost id = Column(Integer,primary_key=True) duvod=Column(String(120))

[sqlalchemy] Re: Oracle sql syntax

2008-12-11 Thread Michael Bayer
I'd try 1 = 0 I dont think oracle has boolean keywords at least last I checked... On Dec 11, 2008, at 4:09 AM, jo wrote: Hi all, I'm trying sqlalchemy with Oracle. Seems Oracle doesn't understand the syntax True = False ... File

[sqlalchemy] Re: Oracle sql syntax

2008-12-11 Thread jo
You are right, Michael, 1=0 works. thank you, j Michael Bayer ha scritto: I'd try 1 = 0 I dont think oracle has boolean keywords at least last I checked... On Dec 11, 2008, at 4:09 AM, jo wrote: Hi all, I'm trying sqlalchemy with Oracle. Seems Oracle doesn't understand the

[sqlalchemy] Re: PickleType copy_values and compare_values bug

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 5:50 AM, Jonathan Marshall wrote: Also I don't agree that the current desired behaviour is documented. See http://www.sqlalchemy.org/docs/05/types.html#types_standard_pickletype and

[sqlalchemy] Variable_TypeByValue(): unhandled data type unicode

2008-12-11 Thread jo
Hi all, I'm using SA with cx_Oracle. In some queries it raises the following error: File /usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py, line 581, in _execute_raw self._execute(context) File /usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py, line 599, in _execute

[sqlalchemy] Re: PickleType copy_values and compare_values bug

2008-12-11 Thread Michael Bayer
the change is in r5461, objects like dicts and lists will compare correctly with no changes. Objects that don't implement __eq__() and are not None will raise a deprecation warning and use the old dumps() method. Docs are updated on the site as well as 05Migration.

[sqlalchemy] Re: ORM lifecycle questions

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 2:04 PM, Ross Vandegrift wrote: Hi guys, I'm somewhat confused about the different lifecycle states of objects that are backed by the SA ORM. According to the SA docs (FWIW, I'm on 0.4), an object is in the Persistent state when it is present in the session and has a

[sqlalchemy] session.add

2008-12-11 Thread n00b
hello, i need to generate a unique number from a table based on the primary key. i used to lock the table (with write) and got what i needed. working with the ORM, though, it seems that session.add(object) functions just as well. at the time of the session.add(), the primary key assigned to the

[sqlalchemy] Re: .compile() not using default params

2008-12-11 Thread zepolen
Ah, makes sense. Thanks. On Dec 11, 5:50 pm, Michael Bayer mike...@zzzcomputing.com wrote: you're compiling the text() construct against the DefaultDialect, when   it needs to be compiled against the PG dialect in order for the :num   bind param to be converted to PG's desired format,

[sqlalchemy] iterate_properties missing in 0.5?

2008-12-11 Thread Jorge Vargas
Hi, has the behavior here http://www.sqlalchemy.org/trac/wiki/FAQ#Whatsthebestwaytofigureoutwhichattributesarecolumnsgivenaclass changed in 0.5? I'm trying that and getting AttributeError: iterate_properties this is my code, so far: klass = model.User def add_user(): obj = klass()

[sqlalchemy] Re: iterate_properties missing in 0.5?

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 7:08 PM, Jorge Vargas wrote: Hi, has the behavior here http://www.sqlalchemy.org/trac/wiki/FAQ#Whatsthebestwaytofigureoutwhichattributesarecolumnsgivenaclass changed in 0.5? I'm trying that and getting AttributeError: iterate_properties this is my code, so far:

[sqlalchemy] Unstable results using lambda function

2008-12-11 Thread channing
I have a weird problem: Two identical functions, created using a lambda from the same issuing identical SQL, return two different answers. I'm embarrassed to say this, but it looks stochastic. I'm running 0.4.2p3 with Python 2.5.2 and Ipython 0.8.1. First, the guided tour. I'm using a lambda

[sqlalchemy] Unstable results using lambda function

2008-12-11 Thread channing
I have a weird problem: Two identical functions, created using a lambda from the same issuing identical SQL, return two different answers. I'm embarrassed to say this, but it looks stochastic. I'm running 0.4.2p3 with Python 2.5.2 and Ipython 0.8.1. First, the guided tour. I'm using a lambda

[sqlalchemy] Unstable results using lambda function

2008-12-11 Thread channing
I have a weird problem: Two identical functions, created using a lambda from the same issuing identical SQL, return two different answers. I'm embarrassed to say this, but it looks stochastic. I'm running 0.4.2p3 with Python 2.5.2 and Ipython 0.8.1. First, the guided tour. I'm using a lambda

[sqlalchemy] Re: Create tables with metadata

2008-12-11 Thread jarrod.ches...@gmail.com
Doesn't get created in the database. How do i add columns to tables already defined in the database after i have reflected them into the metadata On Dec 12, 12:59 am, Empty mtr...@gmail.com wrote: Hi, On Thu, Dec 11, 2008 at 8:12 AM, jarrod.ches...@gmail.com jarrod.ches...@gmail.com