Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Sergi Pons Freixes
2015-09-22 11:52 GMT-07:00 Sergi Pons Freixes : > 2015-09-22 10:41 GMT-07:00 Mike Bayer : > >> >> So one more time, with all detail possible; attached is an env.py script >> and a full log of all SQL emitted and commands; we have alembic_version is

[sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Yegor Roganov
Just do it in Python: res = [] for hpoint in session.query(HistoryPoint).all(): res.setdefault(hpoint.vehicle_id, []).append({'id':hpoint.id,'location': str(hpoint.location)}) On Tuesday, September 22, 2015 at 6:48:14 PM UTC+3, Johnny W. Santos wrote: > > Supose I have the models below, how

[sqlalchemy] has anyone used/abused events to reflect db changes on cached orm objects?

2015-09-22 Thread Jonathan Vanasco
This is, admittedly, an abuse of SqlAlchemy. I'm wondering if anyone else has dealt with this situation before and how they handled it. We have a handful of situations where SqlAlchemy generates a raw sql update against a table. Something like _table = model.Foo.__table__

Re: [sqlalchemy] has anyone used/abused events to reflect db changes on cached orm objects?

2015-09-22 Thread Jonathan Vanasco
What haven't you thought of, Michael Bayer? Is there anything SqlAlchemy can't do?!?!? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Sergi Pons Freixes
2015-09-22 10:44 GMT-07:00 Mike Bayer : > > > On 9/22/15 1:41 PM, Sergi Pons Freixes wrote: > > Additional update: If on the env.py I substitute "__table_args__ = > {'schema': 'notifications'}" for "__table_args__ = {'schema': > 'notifications'}" and rerun alembic twice

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Sergi Pons Freixes
2015-09-22 10:41 GMT-07:00 Mike Bayer : > > So one more time, with all detail possible; attached is an env.py script > and a full log of all SQL emitted and commands; we have alembic_version is > created in "public", the two tables created only in "notifications", no >

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Mike Bayer
On 9/22/15 2:25 PM, Sergi Pons Freixes wrote: 2015-09-22 10:44 GMT-07:00 Mike Bayer >: On 9/22/15 1:41 PM, Sergi Pons Freixes wrote: Additional update: If on the env.py I substitute "__table_args__ = {'schema':

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Mike Bayer
On 9/22/15 1:41 PM, Sergi Pons Freixes wrote: Additional update: If on the env.py I substitute "__table_args__ = {'schema': 'notifications'}" for "__table_args__ = {'schema': 'notifications'}" and rerun alembic twice again (assuming we start on a clean database), alembic_version is created

[sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Yegor Roganov
Correction: res = {} for hpoint in session.query(HistoryPoint).all(): res.setdefault(hpoint.vehicle_id, []).append({'id':hpoint.id,'location': str(hpoint.location)}) But it will yield a dict, not an array of single-value dicts as requested (are you sure this is what you want? anyways, it's

Re: [sqlalchemy] has anyone used/abused events to reflect db changes on cached orm objects?

2015-09-22 Thread Mike Bayer
On 9/22/15 1:52 PM, Jonathan Vanasco wrote: This is, admittedly, an abuse of SqlAlchemy. I'm wondering if anyone else has dealt with this situation before and how they handled it. We have a handful of situations where SqlAlchemy generates a raw sql update against a table. Something like

Re: [sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Johnny W. Santos
Anyway thanks, it'll help a lot. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to

Re: [sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Johnny W. Santos
Yes, but I think this will be expensive to arrange it with python because I need to return everything at once. I though I could just group_by with some annotation, but I couldn't figure out how. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Sergi Pons Freixes
Additional update: If on the env.py I substitute "__table_args__ = {'schema': 'notifications'}" for "__table_args__ = {'schema': 'notifications'}" and rerun alembic twice again (assuming we start on a clean database), alembic_version is created on the 'notifications' schema, t1 and t2 on

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Mike Bayer
On 9/22/15 3:43 PM, Sergi Pons Freixes wrote: 2015-09-22 11:52 GMT-07:00 Sergi Pons Freixes >: 2015-09-22 10:41 GMT-07:00 Mike Bayer >: So one more time, with

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Sergi Pons Freixes
2015-09-22 16:24 GMT-07:00 Mike Bayer : > Revision runs fine, but now when I run the upgrade it does not find the > alembic_version table (attached logs)... I suspect that the search_path is > restored so that it takes notifications again by default? > > > yes > > >

Re: Drop followed by generation of Foreign Keys

2015-09-22 Thread Mike Bayer
On 9/22/15 6:49 PM, Sergi Pons Freixes wrote: 2015-09-22 15:06 GMT-07:00 Mike Bayer >: OK, the only possible way this would happen is if "SELECT current_schema()" were returning the name "notifications", and I went back

Re: [sqlalchemy] Encapsulate multiple columns into one

2015-09-22 Thread Mike Bayer
On 9/22/15 7:18 AM, Yegor Roganov wrote: I know that I can encapsulate multiple columns into one using either composite column or hybrid_property, but unfortunatelly neither suits me 100%. Let's say I have a `File` model which includes fields `id`, 'file_name`, `storage_type`, and there is

[sqlalchemy] Encapsulate multiple columns into one

2015-09-22 Thread Yegor Roganov
I know that I can encapsulate multiple columns into one using either composite column or hybrid_property, but unfortunatelly neither suits me 100%. Let's say I have a `File` model which includes fields `id`, 'file_name`, `storage_type`, and there is a `get_url` python function that when given

[sqlalchemy] How to query for something like this?

2015-09-22 Thread Johnny W. Santos
Supose I have the models below, how could I query for a result like this: [ {1: [{"id": 3, "location": "POINT(23.23423423 54.234524234)"},{"id": 4, "location": "POINT(23.23423423 54.234524234)"}]}, {2: [{"id": 45, "location": "POINT(78.23423423 43.234524234)"},{"id": 67, "location":