python sqlite3的常规使用,pythonsqlite3常规,python sqlit
python sqlite3的常规使用,pythonsqlite3常规,python sqlit
python sqlite3的常规使用
python sqlite3的常规使用
#Filename: DBcon.pyimport sqlite3import timeconn=sqlite3.connect(r'D:\Exercise\Python\DB\example.db')c=conn.cursor()c.execute("Create table if not exists stocks (date text, trans text, symbol text, qty real, price real)")flag=raw_input("Do you wanna clean the table?(y/n):")if flag=='y': c.execute("delete from stocks")c.execute("Insert into stocks values('"+time.strftime('%Y-%m-%d %H:%m:%S')+"', 'Buy','Rhatd',1000,23.14)")conn.commit()c.execute('select * from stocks')res=c.fetchall()count=0print resprint '-'*60for line in res: for f in line: count=count+1 print count,f, printprint '-'*60print '-'*60print 'There are %d records!' %countc.close()conn.close()
相关内容
- 从python list中删除元素,pythonlist,python的list非
- python cache decorator,pythondecorator,在程序中缓存经常用到
- 让python的json.dumps输出中文,pythonjson.dumps,python的json.
- python使用ctypes调用libcaptcha生成验证码,ctypeslibcaptcha,
- python 中参数用法大全,python参数用法大全,#!/usr/bin/e
- python文件搜索代码,python搜索代码,python3.2实现,
- python抓取Bing每天的桌面,并设置为自己的桌面,pytho
- python random从集合中随机选择元素,pythonrandom,使用pyth
- python安装mysql包命令,pythonmysql命令,python使用easy
- python在win7(32位和64)下安装PIL,win7pil,PIL是python下的
评论关闭