>
>
> there's nothing built in that does that. you might build your own using
> the way that tometadata() works to provide clues.
>
>
>
So, something like this? (Ignoring schema for now)
def copyinmetadata(table, to_name):
"""Make copy of table in own metadata"""
metadata = table.metadata
assert metadata.tables.get(to_name, None) is None, \
'Copy/Rename target %s already exists in metadata' % to_name
args = []
for c in table.columns:
args.append(c.copy())
for c in table.constraints:
args.append(c.copy())
return Table(to_name, metadata, *args)
def renameinmetadata(table, to_name):
"""Rename table in own metadata"""
metadata = table.metadata
new_table = copyinmetadata(table, to_name)
metadata.remove(table)
return new_table
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---