Re: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 1:59 PM, Daniel Cardin wrote: > 1. I always expected that, with any reasonably non-trivial app, I would > inevitably need to fall back to using their env.py. My hope was that for > simpler cases, since this is a testing tool, there would be a way to not > require any

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Daniel Cardin
1. I always expected that, with any reasonably non-trivial app, I would inevitably need to fall back to using their env.py. My hope was that for simpler cases, since this is a testing tool, there would be a way to not require any changes to their env.py by default. Ultimately I can document

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 12:02 PM, Daniel Cardin wrote: > So, yes I mean "commands" as in `alembic.command.upgrade()`. > > The idea would be that the library defines an env.py (e.g. the important > portion of which would look something like:) > ... > > connectable =

Re: Invoke commands with custom env.py from library

2020-03-05 Thread Daniel Cardin
So, yes I mean "commands" as in `alembic.command.upgrade()`. The idea would be that the library defines an env.py (e.g. the important portion of which would look something like:) ... connectable = context.config.attributes.get("connection", None) with self.connection.connect() as connection:

Re: [sqlalchemy] Memory management in sqlalchemy

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 10:17 AM, Adrien Blin wrote: > 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") >

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: Invoke commands with custom env.py from library

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 8:08 AM, Daniel Cardin wrote: > I am attempting to write a library which invokes alembic commands, while > referencing the migrations of a separate package which has installed said > library. > > The intent here, is for the library to invoke the alembic commands with

Re: [sqlalchemy] Memory management in sqlalchemy

2020-03-05 Thread Mike Bayer
On Thu, Mar 5, 2020, at 5:17 AM, Adrien Blin wrote: > > > I'll try to recreate the issue for you to test it, but my question really is > : Is there something I didn't get about memory usage in sqlalchemy, meaning, > is it normal for it to retain objects in memory, and if so, how can we get

Re: Alembic: Change the order of the columns for a table

2020-03-05 Thread David Siller
Hello Mike, sorry for not having provided the table definition initially. You are absolutely right, I used to define the tables and columns in a declarative way and had the uniqueness-constraints defined on the columns. As you proposed, setting the unique=False and index=False before invoking

Invoke commands with custom env.py from library

2020-03-05 Thread Daniel Cardin
I am attempting to write a library which invokes alembic commands, while referencing the migrations of a separate package which has installed said library. The intent here, is for the library to invoke the alembic commands with an env.py defined in that package. This seems to work through

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