Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-16 Thread Adrien Berchet
; # 2. just split on the dot, assume anonymized name > return compiled.split(".")[0] > > a test suite is included in the attached along with a crazy table name > test. > > > > On Wed, Apr 15, 2020, at 10:33 AM, Adrien Berchet wrote: > > > Yes, the fi

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-15 Thread Adrien Berchet
func.ST_AsGeoJSON(Lake, 'geom')]) > > ? > > that is, users definitely need this goofy "Table" syntax, right? > > > > On Wed, Apr 15, 2020, at 7:15 AM, Adrien Berchet wrote: > > Ok, thank you for your advice, following it I tried the following (in > g

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-15 Thread Adrien Berchet
gt; OK so use the "t" form with the "geom" name sent as a string, it wants the > whole row so this is a special Postgresql syntax.There are many ways to > make it output this and it depends on the specifics of how this is being > rendered. it may require

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-14 Thread Adrien Berchet
it's not going to be any easier to get SQLAlchemy to > render "t" than it is "t.*". it wants to name columns. > > > > On Tue, Apr 14, 2020, at 9:45 AM, Adrien Berchet wrote: > > I just found that in fact it is possible to just pass the table name to >

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-14 Thread Adrien Berchet
:23, Mike Bayer a écrit : > and you can't say "SELECT t.d, t.geom" ? There really should be no > difference between "t.*" and "t.id, t.geom". > > > > On Tue, Apr 14, 2020, at 5:31 AM, Adrien Berchet wrote: > > The "column names" issue

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-14 Thread Adrien Berchet
, ... And I can't find any way to pass the names to the ROW() constructor: https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS Le mardi 14 avril 2020 00:47:28 UTC+2, Mike Bayer a écrit : > > > > On Mon, Apr 13, 2020, at 6:25 PM, Adrien Berchet wrot

Re: [sqlalchemy] Define a GenericFunction that passes all columns

2020-04-13 Thread Adrien Berchet
Hello there I tried to integrate your POC in GeoAlchemy2 in the following PR: https://github.com/geoalchemy/geoalchemy2/pull/258 It is almost working but the ST_AsGeoJSON() function needs a record, not a list of columns. So the query should be like: > SELECT ST_AsGeoJSON(t.*) > FROM t; > >

Re: [sqlalchemy] Memory management in sqlalchemy

2020-03-05 Thread Adrien Blin
I tried strong referencing the objects stored in the session using : def strong_reference_session(session): @event.listens_for(session, "pending_to_persistent") @event.listens_for(session, "deleted_to_persistent") @event.listens_for(session, "detached_to_persistent")

Re: [sqlalchemy] Memory management in sqlalchemy

2020-03-05 Thread Adrien Blin
I am using memory_profiler (https://pypi.org/project/memory-profiler/) to measure the memory usage. I reduced the code to just the request to see ifthe issue only comes from here : import gc import sqlalchemy.orm.session as s from MyDatabase.model.Table import Table from memory_profiler

[sqlalchemy] Memory management in sqlalchemy

2020-03-04 Thread Adrien Blin
Hello, I'm having troubles understanding how to deal with memory management with sqlalchemy. Here is my issue. I have a big script requesting data from a PostgreSQL DB. I process this data, and insert the generated data in my DB. On the beggining of the process, I request an object from my DB

Re: [sqlalchemy] declarative one to many relationship with composite primary key

2010-11-17 Thread Adrien Saladin
On Wed, Nov 17, 2010 at 1:16 AM, Michael Bayer mike...@zzzcomputing.com wrote: ForeignKeyConstraint needs to go into __table_args__ when using declarative. http://www.sqlalchemy.org/docs/orm/extensions/declarative.html#table-configuration Thanks for the note. I have updated my test script to

Re: [sqlalchemy] declarative one to many relationship with composite primary key

2010-11-17 Thread Adrien Saladin
On Wed, Nov 17, 2010 at 4:58 PM, Michael Bayer mike...@zzzcomputing.com wrote: OK its actually a huge SQLA bug that an error isn't raised for that, which is surprising to me, so I created and resolved #1972 in r67d8f4e2fcb9.   __table_args__ is expected to be a tuple or dict, so now an error

[sqlalchemy] declarative one to many relationship with composite primary key

2010-11-16 Thread Adrien
Hi list, Sorry if this is trivial, I'm relatively new to sqlalchemy. I'm trying to set a one to many relationship between class Foo and class Bar (ie Foo should have a list of Bars). Foo has a composite primary key. # from sqlalchemy import * from sqlalchemy.orm