发布网友 发布时间:2022-05-04 11:50
共4个回答
懂视网 时间:2022-05-04 16:12
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 sqlite3 import os,sys DATABASE = 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()
热心网友 时间:2022-05-04 13:20
这样的插入语句是没有条件的,热心网友 时间:2022-05-04 14:38
insert语句中不能出现where子句热心网友 时间:2022-05-04 16:12
up