[sqlalchemy] Change relationship order_by on runtime

2011-10-25 Thread neurino
I need to change a collection order_by when a parent instance mapped attribute changes. Something like this: parents = Table('parents', metadata, Column('id', Integer, primary_key=True) Column('reverse', Boolean, primary_key=True) ) items =

Re: [sqlalchemy] Change relationship order_by on runtime

2011-10-25 Thread neurino
On Oct 25, 2011, at 5:02 AM, neurino wrote: I need to change a collection order_by when a parent instance mapped attribute changes. Something like this: parents = Table('parents', metadata, Column('id', Integer, primary_key=True) Column('reverse

[sqlalchemy] Self populating a new instance relationships, best practice

2011-10-04 Thread neurino
add all children every time I instantiate a new parent? Thanks for your support neurino -- 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

Re: [sqlalchemy] Self populating a new instance relationships, best practice

2011-10-04 Thread neurino
it belongs I wish I can create also needed UserLayers accordingly to save relative data. Little mind map: http://postimage.org/image/286v46m10/ Thanks for your support neurino On Tue, Oct 4, 2011 at 3:17 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Oct 4, 2011, at 8:21 AM, neurino wrote

Re: [sqlalchemy] Relationship spanning on multiple tables

2011-08-11 Thread neurino
neurino On Tue, Aug 2, 2011 at 9:43 AM, neurino neur...@gmail.com wrote: Sorry Michael, there was a typo in my code, due to some wrong copy/paste or search/replace I guess, I'm afraid. The error I reported comes up mapping to `TransmLimit` and not `SurfaceRes` (which is the one already

Re: [sqlalchemy] Relationship spanning on multiple tables

2011-08-02 Thread neurino
patience. neurino On Mon, Aug 1, 2011 at 11:14 PM, Michael Bayer mike...@zzzcomputing.comwrote: 'transm_limit': relationship(SurfaceRes, single_parent=True, #uselist=False, #primaryjoin=and_( #user_stratigraphies.c.id_prov==provinces.c.id

[sqlalchemy] Relationship spanning on multiple tables

2011-08-01 Thread neurino
=True` initialization fails. I just need these to get (not even set) some values with convenience of SA attributes. I published a working example on pastebin: http://pastebin.com/RsZ6GCRq I hope someone can sort out this thing, thank you. Greetings neurino -- You received this message because

Re: [sqlalchemy] orm mapper polymorphic_identity as collection

2011-07-29 Thread neurino
table (holding type name adn so on) or not? Probably reading docs better I'd get the answer by myself so don't mind... I'll post results if I reach some good point. Thanks again neurino On Fri, Jul 29, 2011 at 4:12 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Jul 28, 2011, at 7:05 PM

[sqlalchemy] orm mapper polymorphic_identity as collection

2011-07-28 Thread neurino
this with two mappings? Any advice? Thanks for your support neurino -- 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 sqlalchemy+unsubscr

Re: [sqlalchemy] orm mapper polymorphic_identity as collection

2011-07-28 Thread neurino
Thanks Michael, my need is quite easy, no need of complex querying. Simply my class represents a Layer and, while quite all layer types (concrete, wood, bricks, etc.) act the same, only one (air) acts in a completely different way. With act I refer to performing calculations on float

Re: [sqlalchemy] orm mapper polymorphic_identity as collection

2011-07-28 Thread neurino
id_type (one of `row` items) in see_what_type. Any advice? Thanks for your support On Fri, Jul 29, 2011 at 12:15 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Jul 28, 2011, at 6:08 PM, neurino wrote: Thanks Michael, my need is quite easy, no need of complex querying. Simply my class

[sqlalchemy] Help with tricky relationship

2011-06-20 Thread neurino
I have a (deep) tree structure main area category criteria inputs all tables with one_to_many relationships except criteria - inputs which is many_to_many. I need to set up a relationship for `main` as list of all distinct inputs of its sub-sub-sub-criteria as in this query:

[sqlalchemy] Composite Foreign Key with ondelete='CASCADE' does not work on mysql

2011-05-30 Thread neurino
bug, something sqlalchemy related or whatever. I know I set `passive_deletes=True`to get MySQL ONDELETE CASCADE take care of it more and more quickly. Any help appreciated, thanks for your support neurino -- You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: Composite Foreign Key with ondelete='CASCADE' does not work on mysql

2011-05-30 Thread neurino
tables definitions 'll look like: sensors = Table('sensors', metadata,     ...     mysql_engine='InnoDB'     ) view_opts = Table('view_opts', metadata,     ...     mysql_engine='InnoDB'     ) On 30 Maj, 17:38, neurino neur...@gmail.com wrote: I have a composite Primary key

[sqlalchemy] setting passive_deletes=True on an already existing database

2011-04-13 Thread neurino
support neurino -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit

[sqlalchemy] Re: spanning relationship on 3 tables fails

2011-02-28 Thread neurino
, data.c.id_acq==acquisitions.c.id, acquisitions.c.id_cu==sensors.c.id_cu), cascade='all, delete-orphan', single_parent=True) }) Now it seems work as expected, thanks. On Feb 28, 1:03 pm, neurino neur...@gmail.com wrote: Sorry if I resume this after two months but I

[sqlalchemy] Re: Operational Error raised by except_

2011-02-22 Thread neurino
I guess since, I learn it now, EXCEPT is not supported by MySQL... I guess I'll have to change my query at all... On Feb 22, 12:57 pm, neurino neur...@gmail.com wrote: I have now problems with except_ in MySQL: the code that worked flawlessly in sqlite now causes an error, seems right after

Re: [sqlalchemy] Re: Operational Error raised by except_

2011-02-22 Thread neurino
, model.Sensor.id_meas==stmt.c.id_meas))) \ .filter(and_(stmt.c.id_cu==None, stmt.c.id_meas==None)) Cheers 2011/2/22 neurino neur...@gmail.com I guess since, I learn it now, EXCEPT is not supported by MySQL... I guess I'll have to change my query at all... On Feb 22, 12:57 pm, neurino neur...@gmail.com

[sqlalchemy] VARCHAR requires a length when rendered on MySQL

2011-02-21 Thread neurino
I'm switching to MySQL from SQLite in my Pylons app and I get this error during setup-app: sqlalchemy.exc.InvalidRequestError: VARCHAR requires a length when rendered on MySQL I noticed some tables had simply Unicode without length but also adding length to all Unicode columns the error keeps

[sqlalchemy] Re: VARCHAR requires a length when rendered on MySQL

2011-02-21 Thread neurino
Please ignore this issue, searched for all Unicode but forgot I also used a String for a column... It works flawlessly, I apologize. On Feb 21, 12:40 pm, neurino neur...@gmail.com wrote: I'm switching to MySQL from SQLite in my Pylons app and I get this error during setup-app

[sqlalchemy] Re: Is it possible to know in advance elements that will be cascade-deleted?

2011-02-04 Thread neurino
, 'cascade', ()): print name Thanks again you for your support On Feb 3, 6:04 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 3, 2011, at 11:58 AM, neurino wrote: That is great! Just for eventual followers I fix imports:    from sqlalchemy.orm import

[sqlalchemy] Is it possible to know in advance elements that will be cascade-deleted?

2011-02-03 Thread neurino
while it shouldn't... Any tips? Thank you for your support neurino -- 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 sqlalchemy+unsubscr

[sqlalchemy] Re: Is it possible to know in advance elements that will be cascade-deleted?

2011-02-03 Thread neurino
the user is smart enough to know that if he deletes an Acquisition he deletes its data too... I'm looking at cascade_iterator def source, I could hack that end enclose directly in my code, the halt_on parameter is unused, as far as I understand. Thanks for your support neurino On Feb 3, 5:19 pm

[sqlalchemy] Re: Operational Error raised by except_

2011-01-13 Thread neurino
( Session.query(model.Sensor) \ .filter(model.Sensor.id_cu==model.ViewOpt.id_cu) \ .filter(model.Sensor.id_meas==model.ViewOpt.id_meas) \ .filter(model.ViewOpt.id_view==1) ) and works perfectly, thanks again! Cheers neurino On Jan 12, 5:28 pm, Michael Bayer mike

[sqlalchemy] Operational Error raised by except_

2011-01-12 Thread neurino
I have this model: ``I organize views with many view_options each one showing a sensor. A sensor can appear just once per view.`` sensors = Table('sensors', metadata, Column('id_cu', Integer, ForeignKey('ctrl_units.id'), primary_key=True, autoincrement=False),

[sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread neurino
` which are order_by compatible? Thanks for your support On Jan 12, 2:38 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 12, 2011, at 7:28 AM, neurino wrote: I have this model: ``I organize views with many view_options each one showing a sensor. A sensor can appear just once

[sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread neurino
...@zzzcomputing.com wrote: On Jan 12, 2011, at 8:46 AM, neurino wrote: I need always the same order_by in all app and it could be subject of modification and / or integration in the near future so which better place than mapper to define it once instead of any time I do a query? It sounds like

[sqlalchemy] Re: spanning relationship on 3 tables fails

2010-12-31 Thread neurino
Thank you Michael, I will try it... next year... ^^ good 2011 again! neurino On Dec 30, 5:45 pm, Michael Bayer mike...@zzzcomputing.com wrote: this is again my error messages not telling the whole story, ill see if i can get the term foreign_keys back in there: mapper(Sensor, sensors

[sqlalchemy] spanning relationship on 3 tables fails

2010-12-30 Thread neurino
I have this 4 tables, the base concept is: `sensor data comes from its id_meas / id_cu pair, I can find id_meas directly in data and id_cu in data parent acquisition.` data = Table('data', metadata, Column('id', Integer, primary_key=True), Column('id_acq', Integer,

[sqlalchemy] execute a sql string passing params as tuple like in python DB API

2010-12-20 Thread neurino
How can I execute a query like if I'm using the normal python DB API, passing params as a sequence and not as a mapping? Something like: myParams = (1, 1, 2, 51, 3, 101, 4, 151, 6, 201, 7, 251) Session.execute( SELECT T.datetime, MAX(T.v0), MAX(T.v1), MAX(T.v2), MAX(T.v3), MAX(T.v4),

[sqlalchemy] Re: execute a sql string passing params as tuple like in python DB API

2010-12-20 Thread neurino
style at all.   You'd need to consult its documentation for details. When using Session, acquire the current connection using conn = Session.connection(). On Dec 20, 2010, at 8:10 AM, neurino wrote: How can I execute a query like if I'm using the normal python DB API, passing params

[sqlalchemy] Re: Use of table aliases

2010-12-16 Thread neurino
Thanks for links, I found `aliased` in docs but not in tutorials, I got errors using it but probably I was using it in the wrong way, now it's clearer. On Dec 16, 2:39 am, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 15, 2010, at 9:04 AM, neurino wrote: Hello I have 2 tables: data

[sqlalchemy] Use of table aliases

2010-12-15 Thread neurino
, data, properties={ 'acquisitions': orm.relationship(Acquisition, backref='data'), }) orm.mapper(Acquisition, acquisitions) Any advice? Thanks for your support neurino -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group

[sqlalchemy] syntax error using in_ and tuple_ in Sqlite

2010-12-09 Thread neurino
I get an OperationalError trying to use tuple_ and in_ in a query with a Sqlite db. This is the query (select the distinct id_acq - id_centr couples not already present in another table) query = model.Session.query( Dato.id_elab, Acquisizione.id_centr)\

[sqlalchemy] Re: syntax error using in_ and tuple_ in Sqlite

2010-12-09 Thread neurino
guess I need to retrieve data from both queries in 2 sets and make difference() between them. Thanks On Dec 9, 3:28 pm, neurino neur...@gmail.com wrote: I get an OperationalError trying to use tuple_ and in_ in a query with a Sqlite db. This is the query (select the distinct id_acq - id_centr

[sqlalchemy] Re: Selective relationship cascade

2010-12-03 Thread neurino
` to get type description, if any, so I realize probably the relationship is not really needed... Any advice welcome anyway... Thank you On Dec 2, 3:55 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 2, 2010, at 6:48 AM, neurino wrote: Let's say I have acquisitions at regular intervals

[sqlalchemy] Selective relationship cascade

2010-12-02 Thread neurino
Let's say I have acquisitions at regular intervals and each acquisition I get different measures. Each meausre has a value and a numeric type id (1 = temperature, 2 = humidity ecc...) I want user to insert text description for type id he knows, if he wants. I end up having this 3 tables:

[sqlalchemy] Re: relationships for no-table-related Class

2010-11-17 Thread neurino
Thanks Michael, this solved most of my doubts. Greetings neurino On Nov 16, 5:51 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 16, 2010, at 4:19 AM, neurino wrote: I didn't mean mapping Root to a Table (if not necessary) is my intent, what I'd like to know is how to get

[sqlalchemy] Re: relationships for no-table-related Class

2010-11-16 Thread neurino
] session.delete(root.areas[0]) session.commit() root.items [area] I hope I has been able to focus on my question now. Thanks for your help neurino On Nov 15, 9:57 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 15, 2010, at 10:46 AM, neurino wrote: Thanks for your answer first. Root

[sqlalchemy] Re: relationships for no-table-related Class

2010-11-15 Thread neurino
So no advice? Are relationships and backref something more than attributes I can setup with a query? Thank you for your support. On Nov 11, 9:45 am, neurino neur...@gmail.com wrote: I have a tree structure Root   |   +--Area   |    |   |    +--SubArea   |    |    |   |    |    +--Item

[sqlalchemy] Re: relationships for no-table-related Class

2010-11-15 Thread neurino
in the situation that 80% of the work is done by sqlalchemy automatically and I'm not sure how to fill the remaining, possibly having both areas and subareas behave at the same way to avoid confusion (just as an example, lazy loading). Thanks for your support neurino On Nov 15, 3:49 pm, Michael

[sqlalchemy] relationships for no-table-related Class

2010-11-11 Thread neurino
= query(Area).all() for area in self.areas: area.parent = self But it won't be the same thing as sqlalchemy `relationship` attributes so: are there alternative solutions more sqlalchemy-like? Any tip appreciated! Thank you for your support Greetings neurino -- You received this message