- attached engine_utility.diff
create_tables and drop_table method for engine/schema
i'm attaching a patch which adds three utility methods onto the engine/schema, it allows for creating and dropping any subset of tables (including all), in the form of create_tables, drop_tables methods, it will does so conditionally based on whether the table exists, provided by a has_table method. a rdbms implementation for has_table is provided for postgres, and unit tests are provided for the functionality.
Comments (5)
-
Account Deleted -
repo owner wow, this is great work ! made use of the topological sort, that is terrific, you really mastered a lot of the patterns ive been using...
question, when would i want to say create_tables() with only_new = False ? is that just to save the extra has_table() call in case I know it wont fail ?
i also will probably switch the name has_table() to table_exists(), since has_table() sounds to me like the engine has the Table in its collection. I also want to add some kind of option to table.create() that does the table_exists() function first, since thats what everyone is looking for....
terrific patch !
-
Account Deleted thanks.
re create_table with only_new = False, yeah.. i wasn't sure on that one, the original even had a delete and then create option, but it seemed better to force explicit delete method calls. i left the only_new in, just because i thought folks might want the option of knowing that they were creating tables in a database that already had them, i don't think its that important, your call.
re table_exists instead of has_table sounds good.
re table.create/table.delete utilizing table_exists, sounds good, although i hope most people will switch over to calling the engine methods, to avoid having to dealing with ordering of table.create/delete statements.
-
repo owner changeset:1327 checks in an initial version of this into the 0.2 series, working just with Postgres at the moment.
-
repo owner - changed status to resolved
the basic functionality of this patch has been implemented in the 0.2 branch. the table sorting function in particular is a built-in method on the MetaData object and is useable for more than just create/drop operations.
- Log in to comment
utility table creation and deletion functions