views:

54

answers:

0

All,

This is a snippet from internet repersent the database table will be used:

>>> from sqlalchemy import Table,Column,Integer,String,MetaData,ForeignKey
>>> metadata=MetaData()
>>> users_table=Table('users',metadata,
          Column('id',Integer,primary_key=True),
          Column('name',String),
          Column('fullname',String),
          Column('password',String)
      )
>>> metadata.create_all(engine)

now the table "users" will be created in the database, and then we can using

>>> mapper(User,users_table)

to mapping the table with a python Class.

My question is, if I want to duplicate the table "users" to "users001"(a deepcopy in database), or I just want rename it to "users_renamed", how I can do that in sqlalchemy?

One approach is using DDL to give SQL stmt directly, but I doubt that will cause impact for the "metadata" settings(not tested), then may I also know how keep sqlalchemy related table setting still works after rename the table?

Thanks.

Rgs, KC