[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 wrote: > Hi, > > On Thu, Dec 11, 2008 at 8:12 AM, jarrod.ches...@gmail.com < > > > > jarrod.ches...@gmail.com> wrote: > >

[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 func

[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 func

[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 func

[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

[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() map

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

2008-12-11 Thread zepolen
Ah, makes sense. Thanks. On Dec 11, 5:50 pm, Michael Bayer 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, %(num)s.    Also im   > not

[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 o

[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 an

[sqlalchemy] ORM lifecycle questions

2008-12-11 Thread Ross Vandegrift
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 record in the database. So if I do something like this: p

[sqlalchemy] Re: save on new objects?

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 12:57 PM, Max Ischenko wrote: > > Are you using Session.mapper ? That's the same behavior the > extension had in 0.4, save-on-init. I don't favor the usage of > Session.mapper. > > I do use Session.mapper. I recall I switched to it since I was > getting "Parent instance

[sqlalchemy] Re: save on new objects?

2008-12-11 Thread Max Ischenko
> > > Are you using Session.mapper ? That's the same behavior the > extension had in 0.4, save-on-init. I don't favor the usage of > Session.mapper. > I do use Session.mapper. I recall I switched to it since I was getting "Parent instance ... is not bound" error with sa.orm.mapper. I hastily

[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: Variable_TypeByValue(): unhandled data type unicode

2008-12-11 Thread Michael Bayer
Look into using the Unicode type for python unicode values. http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html?highlight=unicode#sqlalchemy.Unicode On Dec 11, 2008, at 12:01 PM, jo wrote: > > Hi all, > > I'm using SA with cx_Oracle. In some queries it raises the following > e

[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 _execu

[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 > http://www.sqlalchemy.org/docs/05/sqlalchemy_types.html#docstrings_sqlalchemy.types_P

[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 under

[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 "/usr/lib/python2.4/site-packages/s

[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(Strin

[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 1

[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, m

[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: 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')) > > _

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

2008-12-11 Thread Michael Bayer
On Dec 11, 2008, at 3:37 AM, Angri wrote: > > 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 p

[sqlalchemy] date in sqlite

2008-12-11 Thread grat
Hi, i have this table: class ZmenaDH(Base): __tablename__="zmenahost" id = Column(Integer,primary_key=True) duvod=Column(String(120)) premiera=Column(Date) id_solo = Column(Integer, ForeignKey('sola.id')) solo = relation("Solo", backref=backref('zmenahost', order_by=id,

[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] save on new objects?

2008-12-11 Thread Max Ischenko
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, class_, oldinit, instance, args, kwargs): if self.sav

[sqlalchemy] Re: Create tables with metadata

2008-12-11 Thread Empty
Hi, On Thu, Dec 11, 2008 at 8:12 AM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > 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 > > _co

[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 = schema.MetaData(_config_d

[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 (a

[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: Oracle sql syntax

2008-12-11 Thread jo
I'm Sorry, unwittingly, I changed the original subject. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this gr

[sqlalchemy] Oracle sql syntax

2008-12-11 Thread jo
Hi all, I'm trying sqlalchemy with Oracle. Seems Oracle doesn't understand the syntax True = False ... File "/usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 599, in _execute raise exceptions.SQLError(context.statement, context.parameters, e) SQLError: (DatabaseErr

[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] 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: 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