[EMAIL PROTECTED] wrote:
> On Wednesday 18 June 2008 17:21:00 Werner F. Bruhin wrote:
>   
>> Michael Bayer wrote:
>>     
>>> On Jun 18, 2008, at 4:05 AM, Werner F. Bruhin wrote:
>>>       
>>>> All other tables (including the full version of preferences) are
>>>> using "metadata = sa.MetaData()", instead of the "metadataMin" I
>>>> use for the prefminimal definition.
>>>>
>>>> I got this working some month ago, but maybe this is not the
>>>> right way to go about it and it bits me now?
>>>>         
>>> using two separate MetaData objects, if I correctly understand
>>> that's what you're doing, is not going to work at all if that
>>> Table has any ForeignKey objects (which it does).   I dont see
>>> the use case for two distinct MDs.
>>>       
>> What I need to do at start up of the application is to check a
>> couple of columns in table "preferences" to check what version the
>> database is, then if it is an older version I do the upgrade of the
>> database (metadata etc) and update the columns in the table.
>>
>> I can not read all the columns of the table as there might be
>> columns defined for this new release which are not present until
>> the upgrade is finished.
>>
>> Would something like this work for me
>> "session.query(Preferences.col1, Preferences.col2)" and have
>> columns defined in the model which are not yet present in the
>> database?
>>
>> If the query approach does not work what alternatives would I have?
>>
>>     
>
> cant u drop the Min-version once u finished using it? thus having only 
> one metadata to same engine at same time.
>   
If I define it using the same metadata I get an error which tells me to 
use "useexisting=True", if I add this to prefminimal_table definition 
and then do:

prefs = session.query(db.prefminimal).get(1)

I get all to columns of preferences which will not work for me.

Maybe I need a separate model (i.e. have "db2.preferences") which only 
has this one minimal defined table and when I am done with it I destroy 
it and use the normal one.

Just tried this:
import model as db
import modelminimal as dbmin

# get the minimal definition and do whatever
prefs = session.query(dbmin.prefminimal).get(1)
print prefs
del prefs
del dbmin

# now read in the normal stuff
prefs = session.query(db.preferences).get(1)
print prefs

It looks like this works in a little test script.  Is anyone/anything 
going to step onto my toes sometimes later doing it this way?

Thanks for being patient with me.
Werner

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to