[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 
 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 = create_engine('postgresql://db2')


 Session = sessionmaker(twophase=True)


 # bind User operations to engine 1, Account operations to engine 2

 Session.configure(binds={User:engine1, Account:engine2})


 session = Session()


 I noticed that this example only deals with two DBs, and the parameter is 
 called twophase. I was wondering if there is any significance of two 
 here? How can I fit my third DB in? Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 reference. I suppose such feature is relatively commonly needed 
among SQLite users isn't it?

On Friday, August 14, 2015 at 3:48:40 PM UTC-7, Jonathan Vanasco wrote:



 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 locks-state and votes COMMIT! or N!
 - round 2, if commit in round 1 was unanimous, it commits. otherwise 
 everyone is told to roll back.

 Since SQLlite doesn't support that, you'd need to write that logic in at 
 the application level.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 locks-state and votes COMMIT! or N!
- round 2, if commit in round 1 was unanimous, it commits. otherwise 
everyone is told to roll back.

Since SQLlite doesn't support that, you'd need to write that logic in at 
the application level.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 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 
 two-phase-commit available in Sqlite, you will need to decide how to handle 
 situations like (but not limited to):

 - the first and second databases committed, but the third database raised 
 an error (you need to undo in the application)
 - the first and second databases committed, but your application was quit 
 before the third database could commit (you need to undo from another 
 application)

 You will have to decide how to handle that at the application and database 
 levels, and then SqlAlchemy can be used to implement that strategy. 

 I just want to be clear -- your concern right now is on the best way to 
 use Sqlite to solve your problem -- not use Sqlalchemy.  Once you figure 
 that out, people here can be more helpful.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 
two-phase-commit available in Sqlite, you will need to decide how to handle 
situations like (but not limited to):

- the first and second databases committed, but the third database raised 
an error (you need to undo in the application)
- the first and second databases committed, but your application was quit 
before the third database could commit (you need to undo from another 
application)

You will have to decide how to handle that at the application and database 
levels, and then SqlAlchemy can be used to implement that strategy. 

I just want to be clear -- your concern right now is on the best way to use 
Sqlite to solve your problem -- not use Sqlalchemy.  Once you figure that 
out, people here can be more helpful.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 5:20:07 PM UTC-7, Jinghui Niu wrote:

 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 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 
 two-phase-commit available in Sqlite, you will need to decide how to handle 
 situations like (but not limited to):

 - the first and second databases committed, but the third database raised 
 an error (you need to undo in the application)
 - the first and second databases committed, but your application was quit 
 before the third database could commit (you need to undo from another 
 application)

 You will have to decide how to handle that at the application and 
 database levels, and then SqlAlchemy can be used to implement that 
 strategy. 

 I just want to be clear -- your concern right now is on the best way to 
 use Sqlite to solve your problem -- not use Sqlalchemy.  Once you figure 
 that out, people here can be more helpful.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.