Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018, 5:24 PM James Couch wrote: > Oops, I missed the part about the bulk update. I suppose that would work > as long as it's keying on the index. The documentation doesn't make it > clear how it picks the index to query on... I assume it inspects the column > properties and

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
Oops, I missed the part about the bulk update. I suppose that would work as long as it's keying on the index. The documentation doesn't make it clear how it picks the index to query on... I assume it inspects the column properties and picks the best one to use behind the scenes? Normally you'd

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
I think I see what you mean. Do an inline query/update, maybe just query by primary index for speed. I guess that won't add too much overhead, I'll give it a shot. On Friday, August 10, 2018 at 1:43:51 PM UTC-5, Mike Bayer wrote: > > You need to copy the keyedtuples into some other data

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
On Friday, August 10, 2018 at 4:03:06 PM UTC-5, Jonathan Vanasco wrote: > > > A quick background on Mike's short answer... Tuples are immutable lists in > Python, and "KeyedTuple" should indicate that you can't change the values. > They're just a handy result storage object, not an ORM object

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Jonathan Vanasco
On Friday, August 10, 2018 at 2:43:51 PM UTC-4, Mike Bayer wrote: > > You need to copy the keyedtuples into some other data structure, like a > dictionary, modify it, then send that data back into updates. Your best > bet is to use the bulk update stuff once you have those dictionaries, see

Re: Run some migration revisions outside of a transaction

2018-08-10 Thread Michał Bultrowicz
Thanks, but how can I inspect the revisions in code? I'd need to provide some special markers on the ones I don't want to surround in a transaction. pt., 10 sie 2018 o 20:50 Mike Bayer napisał(a): > On Fri, Aug 10, 2018 at 2:00 PM, Michał Bultrowicz > wrote: > > Hey! > > > > What approach

Re: Run some migration revisions outside of a transaction

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018 at 2:00 PM, Michał Bultrowicz wrote: > Hey! > > What approach would you recommend if we want to run some revisions outside > of a transaction, but then run the other ones normally? > > Let me illustrate that. Let's say we have revisions 1,2,3,4,5. The database > is currently

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Mike Bayer
You need to copy the keyedtuples into some other data structure, like a dictionary, modify it, then send that data back into updates. Your best bet is to use the bulk update stuff once you have those dictionaries, see

Run some migration revisions outside of a transaction

2018-08-10 Thread Michał Bultrowicz
Hey! What approach would you recommend if we want to run some revisions outside of a transaction, but then run the other ones normally? Let me illustrate that. Let's say we have revisions 1,2,3,4,5. The database is currently at revision 1, so we need to run 2-5. The problem is that 4 is an

[sqlalchemy] Re: Patterns for building with SQLAlchemy / asyncio

2018-08-10 Thread bkc
Mike, Thanks for the pointer to your enlightening post http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/ --

[sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
Hey all. Long time lurker, first time poster. I'm using sqlalchemy ORM. We have a fairly decent sized data set, and one table has a pretty large number of columns, some of them with foreignkeys. I found that limiting a query to specific columns speeds up the time it takes to come back with a

Re: autogenerate revision fails in a multi-db project generated with: `alembic init --template multidb alembic`

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018 at 6:47 AM, wrote: > Hello > > I'm trying to use alembic to generate a migration file in a multi-db > environment. I first created the project using `alembic init --template > multidb alembic` > and then hack the `env.py` script (didn't touch to `run_migration_online`) > to

[sqlalchemy] Using a declarative model for Flask SQL Alchemy

2018-08-10 Thread Nevinyrral
Hello, I am confused on how to dynamically pass in the tablename for a model. I want my front end to query a GET request with tablename and some other parameters I have 5 tables (could be more later on) that are the exaclt same in columns . How do i make it so these GET requests can

autogenerate revision fails in a multi-db project generated with: `alembic init --template multidb alembic`

2018-08-10 Thread rdebroiz
Hello I'm trying to use alembic to generate a migration file in a multi-db environment. I first created the project using *`alembic init --template multidb alembic`* and then hack the `env.py` script *(didn't touch to `run_migration_online`)* to suit my needs. Here is the error I got after