On Jul 20, 2006, at 1:02 PM, Randall Smith wrote:

> I'm writing tests for an app now and need a test database.  I've  
> decided
> to use sqlite, though production is Postgres.  I've dreaded the  
> thought
> of populating the test database because there are many tables and
> constraints which means I have to populate them in the correct  
> order, etc.
>
> SA seems to have some ability to determine dependencies as  
> demonstrated
> in metadata.create_all().  I'm wondering if it is feasible to use  
> those
> abilities to determine the order in which tables must be  
> populated.  For
> example.  Say I have tables A, B, C, and D.  My test requires table C
> and C depends on D, but not A and B.  Therefore I must populate  
> tables D
> and C (in that order) to run the test.  Does SA contain functionality
> that could aid in this process?
>

sure, try this:

        for t in metadata.table_iterator():
                <do something with t>

> When it comes to syncing, can an object be copied from one session to
> another, then flushed?
>

that is the documented purpose of the merge() function, although merge 
() currently doesnt copy the unsaved changes across.  for now you can  
detach a loaded object from one session and place in the other, or  
perhaps use copy(), although if you copy() you have to go in and  
surgically remove some identifying information so that the sessions  
dont get confused.

so the answer is, "sort of.  want to help getting it to work?"





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to