Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-23 Thread Michael Bayer
On May 22, 2011, at 5:43 AM, Faheem Mitha wrote: [This message has also been posted.] On Fri, 20 May 2011 09:44:36 -0400, Michael Bayer mike...@zzzcomputing.com wrote: OK so not just schema names, table structure as well. So yeah so you're using the same classes among entirely different

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-22 Thread Faheem Mitha
[This message has also been posted.] On Fri, 20 May 2011 09:44:36 -0400, Michael Bayer mike...@zzzcomputing.com wrote: OK so not just schema names, table structure as well. So yeah so you're using the same classes among entirely different databases essentially, so yeah just like our tests

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-20 Thread Faheem Mitha
On Fri, 20 May 2011 00:52:28 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On May 19, 2011, at 5:24 PM, Faheem Mitha wrote: Unfortunately, that is not true. (So I guess just leaving the structure alone and switching dbs will not work.) There are 4 possible different database

Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-20 Thread Michael Bayer
On May 20, 2011, at 4:48 AM, Faheem Mitha wrote: On Fri, 20 May 2011 00:52:28 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On May 19, 2011, at 5:24 PM, Faheem Mitha wrote: Unfortunately, that is not true. (So I guess just leaving the structure alone and switching dbs will not

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Faheem Mitha
Hi, I'm belatedly following up on this earlier thread from October 2010. I decided to go back to it and figure out what the problem was. So, I created a working minimal example. I posted on StackOverflow, but it doesn't seem to have attracted much interest, so I'm copying it here. The SO link is

Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Michael Bayer
On May 19, 2011, at 5:04 AM, Faheem Mitha wrote: from sqlalchemy import * from sqlalchemy.orm import * def make_pheno_table(meta, schema, name='pheno'): pheno_table = Table( name, meta, Column('patientid', String(60), primary_key=True), schema=schema, )

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Faheem Mitha
Hi Michael, Thanks for the reply. On Thu, 19 May 2011 10:59:18 -0400, Michael Bayer mike...@zzzcomputing.com wrote: I'm sure I mentioned earlier, one of the reasons you're finding this difficult is because of this type of pattern, where you're calling mapper() and Table at a different scope

Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Michael Bayer
On May 19, 2011, at 4:02 PM, Faheem Mitha wrote: Hi Michael, Thanks for the reply. On Thu, 19 May 2011 10:59:18 -0400, Michael Bayer mike...@zzzcomputing.com wrote: I'm sure I mentioned earlier, one of the reasons you're finding this difficult is because of this type of pattern,

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Faheem Mitha
Hi Michael, On Thu, 19 May 2011 16:13:49 -0400, Michael Bayer mike...@zzzcomputing.com wrote: Dont wipe anything clean - keep the state of each set of stuff separate. A global dictionary perhaps, with an record inside for each configuration. Could you elaborate on what you have in mind?

Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Michael Bayer
On May 19, 2011, at 4:48 PM, Faheem Mitha wrote: Hi Michael, On Thu, 19 May 2011 16:13:49 -0400, Michael Bayer mike...@zzzcomputing.com wrote: Dont wipe anything clean - keep the state of each set of stuff separate. A global dictionary perhaps, with an record inside for each

[sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Faheem Mitha
On Thu, 19 May 2011 16:57:14 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On May 19, 2011, at 4:48 PM, Faheem Mitha wrote: Hi Michael, On Thu, 19 May 2011 16:13:49 -0400, Michael Bayer mike...@zzzcomputing.com wrote: Dont wipe anything clean - keep the state of each set of stuff

Re: [sqlalchemy] Re: creating tables and mappers multiple times in the same python script

2011-05-19 Thread Michael Bayer
On May 19, 2011, at 5:24 PM, Faheem Mitha wrote: Unfortunately, that is not true. (So I guess just leaving the structure alone and switching dbs will not work.) There are 4 possible different database layouts. Also, there can be multiple schemas in each database. So you have a model with