On Mar 22, 2011, at 3:56 PM, Jay Pipes wrote:

> On Tue, Mar 22, 2011 at 3:12 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
>> if you say this:
>> 
>> Table('sometable', MetaData(), autoload=True, autoload_with=some_engine)
>> 
>> its not looking for "changes", its reflecting the entire form of that table 
>> brand new, each time. This because the MetaData() object is empty.  If OTOH 
>> you were to call the"Table()" constructor multiple times with the same table 
>> name and the *same* MetaData object, nothing happens on the second try - the 
>> existing Table is used.   The example code you had seems to be doing the 
>> former, reflecting each time on MetaData().     So it is calling "PRAGMA 
>> table_info(tablename)" each time.
>> 
>> As far as why it fails in your specific case, I couldn't say for sure, but 
>> it seems possible that Migrate's practice of dropping the whole table, 
>> copying to a temp table, then copying back to the original table may be part 
>> of the problem.  Perhaps the pysqlite or sqlite3 does not see the proper 
>> state when PRAGMA table_info() is used.    Turning on echo='debug' would 
>> illustrate the full SQL conversation occurring with the SQLite database.
> 
> The test case executes the command `sqlite3
> glance_test_migration.sqlite ".schema images"` directly after doing:
> 
> images_table = Table('images', MetaData(), autoload=True,
> autoload_with=self.engine)
> 
> As you can see from the output of the test case, the images_table.c
> contains different columns than what is output by the sqlite3 command.
> That is why I think it's an SA problem and nothing to do with the
> migrate script.

Running with "sqlite3" executes a brand new process with all new state, whereas 
using "engine" uses a SQLite connection that has remained established 
throughout the entire conversation.

Did you run with echo='debug' yet ?


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to