Re: [sqlalchemy] order_by(None) for joinedload subclause queries?

2014-12-30 Thread Adam Feuer
On Tue, Dec 30, 2014 at 8:24 PM, Michael Bayer wrote: > The first two parts, writing the joins and orderings and potentially > aliasing them (or not), is up to you in that case, so you retain full > control over how the query is rendered. > > Michael, Cool, thanks for the explanation. That soun

Re: [sqlalchemy] order_by(None) for joinedload subclause queries?

2014-12-30 Thread Michael Bayer
Adam Feuer wrote: > On Tue, Dec 30, 2014 at 4:09 PM, Michael Bayer > wrote: > you either need to take order_by off the relationship(), probably the best > idea here if ordering isn’t important, or otherwise skip joinedload(), write > out the joins yourself an

Re: [sqlalchemy] Re: can someone tell me how to reset Alembic back to the state of my DB

2014-12-30 Thread AM
Blow away the alembic versions table from the database and the folder with the versions file and patches files on disk and you should be good to go. HTH AM On 12/30/2014 06:01 PM, dewey wrote: Ok, I went ahead and just copied all the data into the clean new schema. So now my actual DB is in s

Re: [sqlalchemy] order_by(None) for joinedload subclause queries?

2014-12-30 Thread Adam Feuer
On Tue, Dec 30, 2014 at 4:09 PM, Michael Bayer wrote: > you either need to take order_by off the relationship(), probably the best > idea here if ordering isn’t important, or otherwise skip joinedload(), > write out the joins yourself and use contains_eager() ( > http://docs.sqlalchemy.org/en/rel

[sqlalchemy] Re: can someone tell me how to reset Alembic back to the state of my DB

2014-12-30 Thread dewey
Ok, I went ahead and just copied all the data into the clean new schema. So now my actual DB is in sync with my SA declarative models. How do I get Alembic to start tracking fresh from this point (ie delete any old revisions or old history)?? Thanks, D On Tuesday, December 30, 2014 7:49:03 PM

[sqlalchemy] can someone tell me how to reset Alembic back to the state of my DB

2014-12-30 Thread dewey
I first installed Alembic and while practicing, I created a first revision. I made some changes in my Declarative models in code And then I used SA to blow away my DB and recreate the whole schema new again And then I made a few more changes to my models (oops) AND loaded a bunch of data Now

Re: [sqlalchemy] order_by(None) for joinedload subclause queries?

2014-12-30 Thread Michael Bayer
Adam Feuer wrote: > Hi, > > We are using SQLAlchemy 0.9.8 on Python 2.7.7 and Postgres 9.3. > > We have a query that uses joinedloads to fully populate some Recipe objects > using a single query. The query creates a large SQL statement that takes 20 > seconds to execute - too long. Here's t

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Michael Bayer
Boris SABATIER wrote: > Thanks Michael for the explanation. > > The solution you link solve work but it doesn't satisfy me. > I use sqlite in developement and postgre in production. That's why I'm > looking for a "configuration's solution". > > If you think it's isn't possible ti work, I will

[sqlalchemy] order_by(None) for joinedload subclause queries?

2014-12-30 Thread Adam Feuer
Hi, We are using SQLAlchemy 0.9.8 on Python 2.7.7 and Postgres 9.3. We have a query that uses joinedloads to fully populate some Recipe objects using a single query. The query creates a large SQL statement that takes 20 seconds to execute - too long. Here's the rendered SQL statement on Pasteb

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Boris SABATIER
Thanks Michael for the explanation. The solution you link solve work but it doesn't satisfy me. I use sqlite in developement and postgre in production. That's why I'm looking for a "configuration's solution". If you think it's isn't possible ti work, I will use postgre in each environement. 201

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Michael Bayer
Boris SABATIER wrote: > @Michael: > Are you sure the default value of isolation_level is None ? OK what I forgot to clarify in my other email is that you’re working with “connect_args” here, which with engine_from_config would not be a separate .ini value in any case; things that go into creat

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Michael Bayer
Michael Bayer wrote: >> >> # ini file : >> sqlalchemy.connect_args = {'isolation_level':None} > > well if this were to be available in an .ini file, that’s not Python code in > an .ini file, it would have to be interpreted, such as: > > sqlalchemy.connect_args = none for those readi

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Boris SABATIER
@Michael: Are you sure the default value of isolation_level is None ? Because when I didn't set to None, I can't use nested session with sqlite and when I set it to None it's works. 2014-12-30 19:42 GMT+01:00 Michael Bayer : > > > Boris Sabatier wrote: > > Hi, > > I need to pass connect_args={'i

Re: [sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Michael Bayer
Boris Sabatier wrote: > Hi, > > I need to pass connect_args={'isolation_level':None} when I create my engine. “None” is the default that’s used if isolation_level is not passed, and means to do nothing. So just don’t pass it, there’s no need to pass “None”. > With create_engine, it's wor

[sqlalchemy] engine_from_config and connect_args

2014-12-30 Thread Boris Sabatier
Hi, I need to pass connect_args={'isolation_level':None} when I create my engine. With create_engine, it's work well. But I would like to use engine_from_config instead of create_engine. This is what I tried and the errors : # ini file : sqlalchemy.connect_args = {'isolation_level':None} # Er

Re: [sqlalchemy] different results by all() vs fetchall()

2014-12-30 Thread Mehdi
Now i get it :) Thanks. On Tuesday, December 30, 2014 8:51:14 PM UTC+3:30, Michael Bayer wrote: > > > > Mehdi > wrote: > > Hi > This is making me mad :( > I have two tables without defined relations in their models(i have to make > my app works with given db) and this is how i make a join query:

Re: [sqlalchemy] different results by all() vs fetchall()

2014-12-30 Thread Michael Bayer
Mehdi wrote: > Hi > This is making me mad :( > I have two tables without defined relations in their models(i have to make my > app works with given db) and this is how i make a join query: > subq = DBSession.query(models.ZT_420_001.ma_master_code, > models.ZT_420_001.ma_region, >

[sqlalchemy] different results by all() vs fetchall()

2014-12-30 Thread Mehdi
Hi This is making me mad :( I have two tables without defined relations in their models(i have to make my app works with given db) and this is how i make a join query: subq = DBSession.query(models.ZT_420_001.ma_master_code, models.ZT_420_001.ma_region, models.ZT_420_0

Re: [sqlalchemy] Re: Column order with declarative base

2014-12-30 Thread Sven Teresniak
Aaah Michael, thanks! This is awesome! I tried a lot and all the time I felt that I missed exact this kind of easy answer. ;) Thanks again. Will implement this now. Sven Am Dienstag, 30. Dezember 2014 17:01:14 UTC+1 schrieb Michael Bayer: > > why don’t you set up your PrimaryKeyConstraint dire

Re: [sqlalchemy] Re: Column order with declarative base

2014-12-30 Thread Michael Bayer
why don’t you set up your PrimaryKeyConstraint directly? class AbstractPK(NameByClass): """ this table defines a frequently used composite primary key """ @declared_attr def key1(cls): return Column(ForeignKey("somekey.keypart1"), primary_key=True) @declared_attr def

Re: [sqlalchemy] Re: Column order with declarative base

2014-12-30 Thread Sven Teresniak
Am Freitag, 2. Juli 2010 02:24:05 UTC+2 schrieb Michael Bayer: > The Column object contains a "sort key" when constructed, against a single > global value, that is used as a sort key when the Table is generated. This > is to get around the fact that the attribute dictionary of the declarative

Re: [sqlalchemy] Column order with declarative base

2014-12-30 Thread Sven Teresniak
Am Freitag, 2. Juli 2010 00:06:10 UTC+2 schrieb Chris Withers: > > Mike Lewis wrote: > > I'm trying to do some DDL creation with declarative base. THe problem > > I am running into is that I'm using a mixin, and it seems that the > > order the columns are being created in is different than the ord