[sqlalchemy] Re: drop_all not working for me
drop_all() doesnt remove Table instances from the metadata. the Table object is a python object, it only represents your real database table. you may well want to call create_all() again using that same Table. On Feb 12, 3:20 pm, percious [EMAIL PROTECTED] wrote: See test case: from turbogears import config from turbogears.database import metadata from turbogears import database from sqlalchemy import Table, Column, Integer, Unicode import sqlalchemy.orm config.update({sqlalchemy.dburi:sqlite:///:memory:}) database.bind_meta_data() Table('t_table', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() Table('t_table_history', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() assert metadata.tables.keys() == ['t_table', 't_table_history'] metadata.drop_all(tables=['t_table_history',]) #fails assert metadata.tables.keys() == ['t_table'] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: drop_all not working for me
On Feb 12, 3:49 pm, Michael Bayer [EMAIL PROTECTED] wrote: drop_all() doesnt remove Table instances from the metadata. the Table object is a python object, it only represents your real database table. you may well want to call create_all() again using that same Table. On Feb 12, 3:20 pm, percious [EMAIL PROTECTED] wrote: See test case: from turbogears import config from turbogears.database import metadata from turbogears import database from sqlalchemy import Table, Column, Integer, Unicode import sqlalchemy.orm config.update({sqlalchemy.dburi:sqlite:///:memory:}) database.bind_meta_data() Table('t_table', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() Table('t_table_history', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() assert metadata.tables.keys() == ['t_table', 't_table_history'] metadata.drop_all(tables=['t_table_history',]) #fails assert metadata.tables.keys() == ['t_table'] Would it make sense to add the following code to line 905 in your schema.py??? if tables is None: self.tables.clear() else: for table in tables: if type(table) is str: del self.tables[table] else: for k, t in self.tables.iteritems(): if t is table: del self.tables[k] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: drop_all not working for me
not if you understood my previous reply, no. On Feb 12, 3:55 pm, percious [EMAIL PROTECTED] wrote: On Feb 12, 3:49 pm, Michael Bayer [EMAIL PROTECTED] wrote: drop_all() doesnt remove Table instances from the metadata. the Table object is a python object, it only represents your real database table. you may well want to call create_all() again using that same Table. On Feb 12, 3:20 pm, percious [EMAIL PROTECTED] wrote: See test case: from turbogears import config from turbogears.database import metadata from turbogears import database from sqlalchemy import Table, Column, Integer, Unicode import sqlalchemy.orm config.update({sqlalchemy.dburi:sqlite:///:memory:}) database.bind_meta_data() Table('t_table', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() Table('t_table_history', metadata, Column('id', Integer, primary_key=True), Column('data', Unicode(255)), ).create() assert metadata.tables.keys() == ['t_table', 't_table_history'] metadata.drop_all(tables=['t_table_history',]) #fails assert metadata.tables.keys() == ['t_table'] Would it make sense to add the following code to line 905 in your schema.py??? if tables is None: self.tables.clear() else: for table in tables: if type(table) is str: del self.tables[table] else: for k, t in self.tables.iteritems(): if t is table: del self.tables[k] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---