[sqlalchemy] Re: Using custom functions and threading (v. 0.4.6)
[mailto:[EMAIL PROTECTED] On Behalf Of Ryan Ginstrom If I start my method calls with begin() would I be able to create functions in the connection object, then use my session object to run queries? Founds this one out for myself: no, it doesn't work g Regards, Ryan Ginstrom --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] assoc-proxy for semi-hidden assoc-objects
hi i have an assoc.object that has some automatic auto-setup behavior for the additional fields (timestamp etc). So for most of the model usage it looks like a hidden one. so 2 questions: 1) can i get that autoset functionality without having explicit assoc.object? i guess column defaults of some sort? 2) if i go for explicit assoc.object, how can i use assoc.proxy - or something similar - to hide the creation of those intermediate objects? i.e. that it looks like plain implicit m2m. In this case the autoset will be triggered at mapperExt or sesseonExt level. TiA svilen --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Searching in related tables
Hi. I have clients(table) with address(related one-to-one) and persons(related one-to-many).. I want to do this: results = ses.query(b.Client).filter(b.Client.address_id==b.Address.id).\ filter(b.Client.id==b.Client_person.client_id).filter(or_(*cols)).all() Using only: results = ses.query(b.Client).filter(or_(*cols)).all() where *cols is for example: b.Address.name.like('%address%') or b.Client_person.surname.like('%surname%') ... When I do not specify the join filter, I get all companies... With join filter, everything works fine. Is there a way to not specify the join filters explicitly?? thx --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Using custom functions and threading (v. 0.4.6)
On Jul 1, 2008, at 10:38 PM, Ryan Ginstrom wrote: Thanks a lot for the information. I'm creating my session class like so: SessionClass = scoped_session(sessionmaker(bind=engine, autoflush=True, transactional=True)) I'm closing out each exposed method call with a self.session.close() If I start my method calls with begin() would I be able to create functions in the connection object, then use my session object to run queries? as long as the session is in a transaction, and its bound to a single engine of some kind, saying session.connection() will give you the same connection each time, so yes. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Searching in related tables
On Jul 2, 2008, at 5:27 AM, [EMAIL PROTECTED] wrote: Hi. I have clients(table) with address(related one-to-one) and persons(related one-to-many).. I want to do this: results = ses.query(b.Client).filter(b.Client.address_id==b.Address.id).\ filter (b.Client.id==b.Client_person.client_id).filter(or_(*cols)).all() Using only: results = ses.query(b.Client).filter(or_(*cols)).all() where *cols is for example: b.Address.name.like('%address%') or b.Client_person.surname.like('%surname%') ... When I do not specify the join filter, I get all companies... With join filter, everything works fine. Is there a way to not specify the join filters explicitly?? query.join(['relation1, 'relation2']) is a quicker way to make the joins. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?
Hello Mike, Thank you very much for answering. I have to admit that I don't understand. session.query(Mytable).add_column(cast(Mytable.colB,Float) / cast(Mytable.colC,Float)).all() gives bad results while session.execute(SELECT * , CAST(Mytable.colB AS FLOAT) / CAST(Mytable.colC AS FLOAT)AS CALCUL FROM Mytable) gives correct results. Thanks Dominique --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] are mapperExtensions inherited?
that is, if i define an extension for a base mapper, will the inheriting one call it? or it has completely separate own extension-list? --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?
On Jul 2, 2008, at 12:38 PM, Dominique wrote: Hello Mike, Thank you very much for answering. I have to admit that I don't understand. session.query(Mytable).add_column(cast(Mytable.colB,Float) / cast(Mytable.colC,Float)).all() gives bad results while session.execute(SELECT * , CAST(Mytable.colB AS FLOAT) / CAST(Mytable.colC AS FLOAT)AS CALCUL FROM Mytable) gives correct results. SQLite has a separate NUMERIC affinity from REAL, and up til this point we've only supported NUMERIC. its just a one liner in that doc which explains a difference. r4889 in the 0.4 branch and r4890 in the trunk adds a separate SLFloat type with FLOAT as the descriptor. If your test is against 0.4 it requires a session.clear() to illustrate identical results to raw SQL so that the integer-based values sent to each MyTable instance come back as floating point. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: are mapperExtensions inherited?
yes they are inherited. each mapper does have its own extension list but the list is formulated while taking into account the extension list of the inherited mapper. This probably does not work for mapper extensions specified with query.options(extensionoption) and I would discourage the usage of that mapper option. On Jul 2, 2008, at 2:21 PM, [EMAIL PROTECTED] wrote: that is, if i define an extension for a base mapper, will the inheriting one call it? or it has completely separate own extension-list? --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?
Mike, I just had a quick look. See further in a moment. Thank you very much for your time, your work and your help. I really appreciate Dominique --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] autoflush and mysql
Hi, I'm just starting out with SQLAlchemy and I encountered some unexpected behavior with autoflush and mysql. I expected that setting autoflush=True would force a flush after every DB call. However, it seems that a flush isn't happening automatically on an add/delete. Here is my test script: ## mysqlflush.py import sqlalchemy as sa from sqlalchemy import orm metadata = sa.MetaData() tmptable_table = sa.Table('TmpTable', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('val', sa.types.String(100), nullable=False) ) class TmpTable(object): def __init__(self,val): self.val = val orm.mapper(TmpTable, tmptable_table) engine = sa.create_engine('mysql://user:[EMAIL PROTECTED]:3306/ test_db', echo=True) metadata.create_all(engine) Session = orm.sessionmaker(bind=engine, autoflush=True, transactional=True)() for i in range(0,100,1): Session.save_or_update(TmpTable(val='blah')) The results of running the test script are: mysql select * from test_db.TmpTable; Empty set (0.00 sec) Am I just not understanding autoflush correctly? Thanks, Andres --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: are mapperExtensions inherited?
On Wednesday 02 July 2008 21:38:24 Michael Bayer wrote: yes they are inherited. each mapper does have its own extension list but the list is formulated while taking into account the extension list of the inherited mapper. This probably does not work for mapper extensions specified with query.options(extensionoption) and I would discourage the usage of that mapper option. and it does not work (of course) if the mapper.extension is appended later that mapper() creation. which is what i do... hmmm. so far i need mapExtensions 3 times, and in 2 of them it cannot be done at mapper() creation - at that time klas.attr is not instrumented yet. On Jul 2, 2008, at 2:21 PM, [EMAIL PROTECTED] wrote: that is, if i define an extension for a base mapper, will the inheriting one call it? or it has completely separate own extension-list? --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: are mapperExtensions inherited?
On Jul 2, 2008, at 3:21 PM, [EMAIL PROTECTED] wrote: On Wednesday 02 July 2008 21:38:24 Michael Bayer wrote: yes they are inherited. each mapper does have its own extension list but the list is formulated while taking into account the extension list of the inherited mapper. This probably does not work for mapper extensions specified with query.options(extensionoption) and I would discourage the usage of that mapper option. and it does not work (of course) if the mapper.extension is appended later that mapper() creation. which is what i do... since you're digging into the datastructure directly anyway, iterate through the mapper's inheritance chain too. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush and mysql
On Jul 2, 2008, at 3:20 PM, andres wrote: Hi, I'm just starting out with SQLAlchemy and I encountered some unexpected behavior with autoflush and mysql. I expected that setting autoflush=True would force a flush after every DB call. However, it seems that a flush isn't happening automatically on an add/delete. Here is my test script: ## mysqlflush.py import sqlalchemy as sa from sqlalchemy import orm metadata = sa.MetaData() tmptable_table = sa.Table('TmpTable', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('val', sa.types.String(100), nullable=False) ) class TmpTable(object): def __init__(self,val): self.val = val orm.mapper(TmpTable, tmptable_table) engine = sa.create_engine('mysql://user:[EMAIL PROTECTED]:3306/ test_db', echo=True) metadata.create_all(engine) Session = orm.sessionmaker(bind=engine, autoflush=True, transactional=True)() for i in range(0,100,1): Session.save_or_update(TmpTable(val='blah')) The results of running the test script are: mysql select * from test_db.TmpTable; Empty set (0.00 sec) the session flushes on every commit(), and when autoflush=True on every Query execution as well. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush and mysql
How is a query execution defined? Is Session.save_or_update() classified as a query execution? I expected an autoflush to occur on each call to save_or_update. On Jul 2, 1:09 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 2, 2008, at 3:20 PM, andres wrote: Hi, I'm just starting out with SQLAlchemy and I encountered some unexpected behavior with autoflush and mysql. I expected that setting autoflush=True would force a flush after every DB call. However, it seems that a flush isn't happening automatically on an add/delete. Here is my test script: ## mysqlflush.py import sqlalchemy as sa from sqlalchemy import orm metadata = sa.MetaData() tmptable_table = sa.Table('TmpTable', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('val', sa.types.String(100), nullable=False) ) class TmpTable(object): def __init__(self,val): self.val = val orm.mapper(TmpTable, tmptable_table) engine = sa.create_engine('mysql://user:[EMAIL PROTECTED]:3306/ test_db', echo=True) metadata.create_all(engine) Session = orm.sessionmaker(bind=engine, autoflush=True, transactional=True)() for i in range(0,100,1): Session.save_or_update(TmpTable(val='blah')) The results of running the test script are: mysql select * from test_db.TmpTable; Empty set (0.00 sec) the session flushes on every commit(), and when autoflush=True on every Query execution as well. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush and mysql
On Jul 2, 2008, at 4:14 PM, andres wrote: How is a query execution defined? Is Session.save_or_update() classified as a query execution? I expected an autoflush to occur on each call to save_or_update. save_or_update() just places an object in the session where it is then pending, dirty or just persistent. No SQL is executed. This is described at: http://www.sqlalchemy.org/docs/05/session.html#unitofwork_using_states where add() is 0.5's term for save_or_update(). --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] A new SQLAlchemy migration toolkit - miruku 0.1a3 has been released
Hi, I've just created a new migration toolkit - miruku. The goal of miruku project is to do the migration work automatically by just one simple command. There is no need to write upgrade script manually and there is no version control mechanism. All you have to do is just keep modifying your model schema code and miruku will do all the upgrading things for you. Now you can download and find simple tutorial at http://trac.ollix.org/miruku/ --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] How to use a custom collection class in stead of InstrumentedList?
SQLAlchemy creates the relationship as a collection on the parent object containing instances of the child object. I think the collection is an instance of sqlalchemy.orm.collections.InstrumentedList. I want to know how to use my own list-like class in stead of the InstrumentedList. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: How to use a custom collection class in stead of InstrumentedList?
I've read the section 'Alternate Collection Implementations' in the documentation just now. Sorry for my carelessness. On 7月3日, 上午11时57分, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: SQLAlchemy creates the relationship as a collection on the parent object containing instances of the child object. I think the collection is an instance of sqlalchemy.orm.collections.InstrumentedList. I want to know how to use my own list-like class in stead of the InstrumentedList. --~--~-~--~~~---~--~~ 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 group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---