建立Python文件alchemy9.py,代码如下:
#!/usr/bin/ python
#encoding:utf8
from sqlalchemy import *
from sqlalchemy.orm import *
#alchemy5实现创建数据库表格功能
from alchemy5 import *
#功能:为数据表创建映射
class User(object):
def __repr__(self):
return '%s(%r, %r)'%(self.__class__.__name__, self.name, self.fullname)
mapper(User, user) #创建映射
u = User()
print u
print u.name
u = ('lei', 'li lei')
print u