[sqlalchemy] DB Redundancy

2009-05-06 Thread Vic
I'm looking for a way to have my DB replicated in REAL TIME to be used in case I lose my primary copy. I saw that the two phase commit exist but I'm not sure if that is the correct option. I have the feeling that it would be abusing a mechanism purposed for correlating to separate DBs and not

[sqlalchemy] Re: DB Redundancy

2009-05-06 Thread Ants Aasma
On May 6, 9:07 am, Vic vctr...@gmail.com wrote: I'm looking for a way to have my DB replicated in REAL TIME to be used in case I lose my primary copy. I saw that the two phase commit exist but I'm not sure if that is the correct option. I have the feeling that it would be abusing a

[sqlalchemy] Re: 0.5.3 ORM, MSSQL and FreeTDS: Invalid Cursor State exception?

2009-05-06 Thread Ed Singleton
If it helps, I have finally got my system working, now using FreeTDS 0.82, SQLAlchemy 0.5.3, pymssql, Python 2.5, (all on Mac Leopard) and SQL Server 2005 (on an WinXP vm). With this setup, your test passes without any problems. I also tried it out using pyodbc 2.1.5 and the test failed

[sqlalchemy] Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
Hello, I would like to implement typical Save / Cancel dialog operating on normal SQLA objects. For that purpose, the most convenient way is to make a shallow copy of an object using copy.copy(obj), let the user edit this object, and on user pressing OK in dialog replace it in SQLA, e.g.

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
u'd better edit a new copy and on save copy all back into original then commit that one, on cancel abandon the new one (but beware of m2m relations if u have them). all else isn't safe/nice IMO. On Wednesday 06 May 2009 17:25:47 Marcin Krol wrote: Hello, I would like to implement typical

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
a...@svilendobrev.com wrote: u'd better edit a new copy and on save copy all back into original then commit that one, on cancel abandon the new one (but beware of m2m relations if u have them). all else isn't safe/nice IMO. To make it specific, should I do smth like: 1. on beginning of

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
sqlalchemy objects always log change events when things are modified. when i need a throwaway version of an object I often use a separate class for that, sometimes just a vanilla object subclass that I set attributes on, i.e. class Lightweight(object): def __init__(self, **kw):

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
the copy can be a dummy non-db-aware - if that is ok in your case there's yet another option; u can just go all over the original object, and on cancel do a rollback, and restore all changed stuff back by hand (eventualy looking at object-state's history). But this assumes short

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
Michael Bayer wrote: sqlalchemy objects always log change events when things are modified. when i need a throwaway version of an object I often use a separate class for that, sometimes just a vanilla object subclass that I set attributes on, i.e. class Lightweight(object): def

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
Hello az, thanks for answer, a...@svilendobrev.com wrote: the copy can be a dummy non-db-aware - if that is ok in your case there's yet another option; u can just go all over the original object, and on cancel do a rollback, and restore all changed stuff back by hand (eventualy looking

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
Marcin Krol wrote: Michael Bayer wrote: sqlalchemy objects always log change events when things are modified. when i need a throwaway version of an object I often use a separate class for that, sometimes just a vanilla object subclass that I set attributes on, i.e. class

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
if you're looking for state between requests you can use an HTTP session for that *SMACK* forehead... Right.. Mental block.. and lightweight objects are great for those since they are easily serializable and use minimal space. Im a little confused, did you originally intend to persist

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
Marcin Krol wrote: if you're looking for state between requests you can use an HTTP session for that *SMACK* forehead... Right.. Mental block.. and lightweight objects are great for those since they are easily serializable and use minimal space. Im a little confused, did you originally

[sqlalchemy] PostgreSQL: subqueries and alias

2009-05-06 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I have noted that with this query: # query is the original query # query_aux is the query required to compute the number of rows returned # by the original query query_aux = sql.select( [sql.func.count()], from_obj=[query]) I get, with

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
one2many are the tricky ones - there's no copy as semantics, there's move. Say again? I can't (shallow) copy one-to-many object to another? Or do you mean: I can't copy it to another object, modify it and then copy it back? shallow? if A points to B1, copying B1 to B2 is ok, but u lose

[sqlalchemy] Advice on many-to-many schema

2009-05-06 Thread James
Hello all, I'm creating a SA model of a many to many relationship, where the association has a particular weight. I've always used straightforward association tables for this task before (with an extra column in the association table for the weight in this case), but was wondering if the

[sqlalchemy] Re: PostgreSQL: subqueries and alias

2009-05-06 Thread Michael Bayer
the implicit behavior might lead to confusion later on. such as: from sqlalchemy import * from sqlalchemy.sql import table, column t1 = table(t1, column(c1), column(c2)) t2 = table(t2, column(c1), column(c2)) s1 = select([t1, t2], use_labels=True) s2 = select([t1, t2],

[sqlalchemy] Rollback behaviour in 0.4.8

2009-05-06 Thread naktinis
I have a session created this way: Session = scoped_session(sessionmaker(autoflush=True, transactional=True)) Then I have this piece of code: print User.query().count() u = User(name='Jim') Session.flush([u]) print User.query().count() Session.rollback() Session.clear() print

[sqlalchemy] Re: Rollback behaviour in 0.4.8

2009-05-06 Thread Michael Bayer
are you using MyISAM tables ? naktinis wrote: I have a session created this way: Session = scoped_session(sessionmaker(autoflush=True, transactional=True)) Then I have this piece of code: print User.query().count() u = User(name='Jim') Session.flush([u]) print User.query().count()

[sqlalchemy] Re: Rollback behaviour in 0.4.8

2009-05-06 Thread naktinis
Oh.. Yes, sorry. That's my mistake, because testing engine created MyISAM tables (they were default) and it broke the tests. Thanks! On May 7, 12:39 am, Michael Bayer mike...@zzzcomputing.com wrote: are you using MyISAM tables ? naktinis wrote: I have a session created this way: Session