[PYTHON] 将perforce的 changelist放到 sqlite 数据库里面
2010-11-02 17:10
459 查看
from P4 import P4 import sqlite3 import time def InsertChanges(): #insert change to db p4=P4() p4.connect() #exittable=cursor.execute("select count(*) from sqlite_master where type='table' and name='changes'") test whether the table existes or not. #print exittable conn=sqlite3.connect("perforceChanges.db") cursor=conn.cursor() try: cursor.execute("drop table changes")#delete the table except: pass cursor.execute("create table changes(change,time,user,client,desc)") changes=p4.run("changes","-m20","-l") for change in changes: ti=time.strftime('%Y/%m/%d %H:%M:%S',time.localtime((float)(change['time']))) t=(change['change'],ti,change['user'],change['client'],change['desc']) cursor.execute("insert into changes values(?,?,?,?,?)",t) conn.commit() cursor.close() conn.close() def PrintChange():#print the changes at db conn=sqlite3.connect("perforceChanges.db") cursor=conn.cursor() rows=cursor.execute("select * from changes") for row in rows: print "changelist:",row[0] print "time:",row[1] print "user:",row[2] print "client:",row[3] print "description:",row[4] print "=======================================================" InsertChanges() PrintChange()
相关文章推荐
- Python数据库访问之SQLite3、Mysql
- 详解Python 数据库 (sqlite3)应用
- python数据库sqlite基础(一)-------数据库创建,表的建立,数据录入,数据查询
- python sqlite3 数据库操作
- python操作数据库之sqlite3打开数据库、删除、修改示例
- Python-数据库SQLite 游标
- SQLite3创建数据库的方法 和 SQLite从Excel文件中导入数据 及 python/qpython sqlite 中文 乱码
- [Python]轻量好用的数据库 SQLite3
- Python实现读写sqlite3数据库并将统计数据写入Excel的方法示例
- Python3数据库模块(sqlite3,SQLite3)
- 【脚本语言系列】关于Python数据库处理SQLite,你需要知道的事
- Python信息采集器使用轻量级关系型数据库SQLite
- Python3-数据库之SQLite
- 通过Load table命令将数据文件加载到Sybase IQ数据库里面的Python脚本
- python中sqlite3对数据库的增删改查
- sqlite3 python 数据库
- python数据库编程_sqlite
- python 分析 nginx 日志 ip 并存入sqlite 数据库
- python向数据库mysql,sqlite3插入外部变量
- WINFORM数据库操作,有点像安装里面的SQLITE