Re: [sqlalchemy] group by and order by aliasing on custom dialects

2018-01-04 Thread Mike Bayer
Please see the merges: https://gerrit.sqlalchemy.org/622 https://gerrit.sqlalchemy.org/621 which should resolve both of these. On Thu, Jan 4, 2018 at 10:37 AM, Mike Bayer wrote: > On Thu, Jan 4, 2018 at 5:46 AM, Florian Apolloner > wrote: >> Hi there, >> >> I am writing a custom dialect and

Re: [sqlalchemy] Extra table name in FROM clause

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 4:08 PM, sector119 wrote: > Hello, > > In this query I get extra (unexpected) "databases" table name in FROM clause > > q = dbsession.query( > meter_readings.c.reading, > database.c.service_id > ). \ > select_from( > database.outerjoin(meter_r

Re: [sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 3:33 PM, sector119 wrote: > Thank you, Mike, but I need something like this > > > type_coerce( > > Database.meters_readings[ > > func.generate_subscripts(Database.meters_readings, 1) > > ], type_=ARRAY(Text) > > )[1] > > > Database.meters_readings is two-dime

[sqlalchemy] Re: Extra table name in FROM clause

2018-01-04 Thread sector119
oops, .filter(database.c.person_id == person_id) fixed the problem. Thanks! четверг, 4 января 2018 г., 23:08:35 UTC+2 пользователь sector119 написал: > > Hello, > > In this query I get extra (unexpected) "databases" table name in FROM > clause > > q = dbsession.query( > meter_readings.c.

[sqlalchemy] Extra table name in FROM clause

2018-01-04 Thread sector119
Hello, In this query I get extra (unexpected) "databases" table name in FROM clause q = dbsession.query( meter_readings.c.reading, database.c.service_id ). \ select_from( database.outerjoin(meter_readings, true()) ).filter(Database.person_id == person_id) Her

Re: [sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread sector119
Thank you, Mike, but I need something like this type_coerce( Database.meters_readings[ func.generate_subscripts(Database.meters_readings, 1) ], type_=ARRAY(Text) )[1] Database.meters_readings is two-dimensional array like [ ['1', '2', '3'], ['4', '5', '6'] ], so Database.m

Re: [sqlalchemy] Re: changing polymorphic identity on the fly

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 11:08 AM, wrote: > Thank you Mike! > > So suppose I have an a Manager object manager and I wanted to promote that > to Engineer: > > # Modify the persisted data of the manager object in the db directly. > session = object_session(manager) > session.execute(manager.__table__

[sqlalchemy] Temporarily disable DB persistence for optimization routine

2018-01-04 Thread Ruben Di Battista
Hello, I'm writing a satellite passage scheduler that has a database persistence layer to store the scheduled passages. The DB schema is organized as follows: - A table storing the satellites (using NORAD No as Primary Key) - A table storing the ground stations where to compute the passages of

Re: [sqlalchemy] Re: changing polymorphic identity on the fly

2018-01-04 Thread jens . troeger
Thank you Mike! So suppose I have an a Manager object *manager* and I wanted to promote that to Engineer: # Modify the persisted data of the manager object in the db directly. session = object_session(manager) session.execute(manager.__table__.update() \ .where(m

Re: [sqlalchemy] trouble with a self-referential query and remote side population

2018-01-04 Thread Mike Bayer
On Wed, Jan 3, 2018 at 7:48 PM, Mike Bayer wrote: > didn't look close yet but you wouldn't want to have foreign() on a > column that is a primary key column. should be on the opposite side > of whatever refers to a primary key. that and, when you use contains_eager you need to tell it what enti

Re: [sqlalchemy] sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper|Product|prd_product, expression 'image.Image' failed to locate a name ("name 'image' is not defined"). If this is a

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 4:43 AM, Abdurrahmane Fourali wrote: > > I have this error when i passed to python3 > in other side all the modules worked fine with python2 so i don't know why > thank's for your help these questions cannot be answered without real code examples in addition to the error an

Re: [sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 6:49 AM, sector119 wrote: > Hello, > > > I try to rewrite "meters_readings[generate_subscripts(meters_readings, > 1)][1]" from plain sql query that works > > with sqlalchemy and > Database.meters_readings[func.generate_subscripts(Database.meters_readings, > 1)][1] doesn't wo

Re: [sqlalchemy] group by and order by aliasing on custom dialects

2018-01-04 Thread Mike Bayer
On Thu, Jan 4, 2018 at 5:46 AM, Florian Apolloner wrote: > Hi there, > > I am writing a custom dialect and sqlalchemy currently generates a statement > like this: > > ``` > SELECT count(some_table.id) AS count_1, some_table.x + some_table.y AS lx > FROM some_table GROUP BY some_table.x + some_tabl

[sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread sector119
Hello, I try to rewrite "meters_readings[generate_subscripts(meters_readings, 1)][1]" from plain sql query that works with sqlalchemy and Database.meters_readings[func.generate_subscripts(Database.meters_readings, 1)][1] doesn't work I get NotImplementedError: Operator 'getitem' is not su

[sqlalchemy] group by and order by aliasing on custom dialects

2018-01-04 Thread Florian Apolloner
Hi there, I am writing a custom dialect and sqlalchemy currently generates a statement like this: ``` SELECT count(some_table.id) AS count_1, some_table.x + some_table.y AS lx FROM some_table GROUP BY some_table.x + some_table.y ORDER BY lx ``` As you can see it uses the alias lx in ORDER BY b

Re: [sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-04 Thread Jevgenij Kusakovskij
I sorted this problem out and, as you predicted, it turned out to be layers upon layers of problems. If you do not mind having a quick look at how I resolved this, I would really appreciate some feedback and a second opinion... I actually missed the main problem initially. It had to do with the

[sqlalchemy] sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper|Product|prd_product, expression 'image.Image' failed to locate a name ("name 'image' is not defined"). If this is a cla

2018-01-04 Thread Abdurrahmane Fourali
I have this error when i passed to python3 in other side all the modules worked fine with python2 so i don't know why thank's for your help