摘要: 1、连接数据库import os,sysPROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))sys.path.insert(0, os.path.join(PROJECT_ROOT, 'lib'))CONFIG_PATH = os.path.join(PROJECT_ROOT,'config.cfg')from sqlalchemy import create_enginefrom sqlalchemy.ext.declarative import declarative_baseimport Co 阅读全文
posted @ 2013-04-26 20:16 glose 阅读(4301) 评论(0) 推荐(0) 编辑
摘要: 登录数据库 [root@localhost tornado]# psql -U luoyun -d luoyun\c dbname切换数据库,相当于mysql的use dbname\l列举数据库,相当于mysql的show databases\dt列举表,相当于show tables\d tblname查看表结构,相当于desc tblname,show columns from tbnamecreatedb 创建一个新的PostgreSQL的数据库(和SQL语句:CREATE DATABASE 相同)createuser 创建一个新的PostgreSQL的用户(和SQL语句:CREATE U 阅读全文
posted @ 2013-04-26 16:02 glose 阅读(348) 评论(0) 推荐(0) 编辑
摘要: yum installpython-psycopg2yum install libvirt-devel 阅读全文
posted @ 2013-04-26 15:26 glose 阅读(135) 评论(0) 推荐(0) 编辑
摘要: fromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemyimportColumn,Integer,StringfromsqlalchemyimportSequencefromsqlalchemy.ormimportsessionmakerBase=declarative_base()fromsqlalchemyimportcreate_engineengine=create_engine('sqlite:///:memory:',echo=True)classUser(Base):__tablename 阅读全文
posted @ 2013-04-26 10:12 glose 阅读(442) 评论(0) 推荐(0) 编辑