[sqlalchemy] Overwriting __init__() after class definition breaks sqlalchemy with declarative

2015-08-14 Thread Eric Atkin
Hi, I've written a class decorator to define a boilerplate __init__ on some of my models that inherit from a declarative_base superclass. The problem is that sqlalchemy.orm.instrumentation._generate_init() has already installed an __init__ and when I overwrite that, things break with object

Re: [sqlalchemy] Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
Oh by the way, I'm using SQLite as backend. On Aug 14, 2015 2:04 AM, Jinghui Niu niujing...@gmail.com wrote: I have three different DBs, one is person.db, another is journal.db, yet another is tag.db. In the documentation it reads: Vertical partitioning places different kinds of objects, or

[sqlalchemy] Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
I have three different DBs, one is person.db, another is journal.db, yet another is tag.db. In the documentation it reads: Vertical partitioning places different kinds of objects, or different tables, across multiple databases: engine1 = create_engine('postgresql://db1') engine2 =

Re: [sqlalchemy] Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Mike Bayer
On 8/14/15 5:07 AM, Jinghui Niu wrote: Oh by the way, I'm using SQLite as backend. On Aug 14, 2015 2:04 AM, Jinghui Niu niujing...@gmail.com mailto:niujing...@gmail.com wrote: I have three different DBs, one is person.db, another is journal.db, yet another is tag.db. In the

Re: [sqlalchemy] Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jonathan Vanasco
twophase deals with the transaction commit protocol , and is unlreated to anything else in your example. (http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.params.twophase) You'd simply create an engine3 and bind whatever object classes to it. FWIW.

Re: [sqlalchemy] Overwriting __init__() after class definition breaks sqlalchemy with declarative

2015-08-14 Thread Mike Bayer
this code is incorrect from a Python perspective. You're removing the original `__init__` method entirely and it is never called; the attempt to call it using super() just calls object.__init__. SQLAlchemy is already decorating the __init__ method of the mapped class so you can't just throw

Re: [sqlalchemy] Overwriting __init__() after class definition breaks sqlalchemy with declarative

2015-08-14 Thread Eric Atkin
This works. Thank you for the quick response and great libraries (I use Mako as well). Eric On Fri, Aug 14, 2015 at 9:07 AM, Mike Bayer mike...@zzzcomputing.com wrote: this code is incorrect from a Python perspective. You're removing the original `__init__` method entirely and it is never

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
Thanks for all these helpful feedback. If I still want to use SQLite, and I still need to do vertical partition, what can I do? Am I out of luck? On Friday, August 14, 2015 at 2:04:37 AM UTC-7, Jinghui Niu wrote: I have three different DBs, one is person.db, another is journal.db, yet

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
Thank you very much Jonathan for your very intuitive analogy! Basically I just want to put people, journal and tag tables(each will potentially be very large) into different DBs, if I write that logic, how can I integrate it with SQLAlchemy? Could you give me a rough idea here? Or point some

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jonathan Vanasco
On Friday, August 14, 2015 at 5:16:48 PM UTC-4, Jinghui Niu wrote: If I still want to use SQLite, and I still need to do vertical partition, what can I do? Am I out of luck? You can, but not with a two-phase commit. Two-phase commit basically works like this: - round 1, everyone

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
Thanks Jonathan for pointing out the direction, it is very helpful to know where I can find more info. On Friday, August 14, 2015 at 5:06:09 PM UTC-7, Jonathan Vanasco wrote: Well, this problem doesn't really have anything to do with SqlAlchemy -- you should probably ask people for advice on

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jonathan Vanasco
Well, this problem doesn't really have anything to do with SqlAlchemy -- you should probably ask people for advice on the Sqlite lists or Stack Overflow. You can segment out your database into 3 files using the example above. You will just run into an issue where -- because there isn't a

[sqlalchemy] Re: Does twophase=True limit to only two databases at the same time?

2015-08-14 Thread Jinghui Niu
Just a thought, if I don't commit those three tables together in my application, can I just use 3 Session objects to commit them separately, without having to worry about this two phase issue? I want to go simple, not sure if I can handle this fancy stuff:) On Friday, August 14, 2015 at