您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

UseSqliteinPython

2025/12/6 12:36:27发布26次查看
import sqlite3import os,sysdatabase = os.path.dirname(__file__) + /sqlite.dbdef test_db():db = sqlite3.connect(database)cur = db.cursor()sql = create table post(id int primary key not null,title char(50),content text,author char(30))data =
import sqlite3import os,sysdatabase = os.path.dirname(__file__) + '/sqlite.db'def test_db(): db = sqlite3.connect(database) cur = db.cursor() sql = ''' create table post( id int primary key not null, title char(50), content text, author char(30) ) ''' data = ''' insert into post(id,title,content,author) values(1,'good news','you win the big prize','admin') ''' print 'run the query' query = select * from post posts = cur.execute(query) for post in posts: print post[1] db.close() if __name__ == '__main__':test_db()
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product