python sqlite 读取数据
2015-05-10 22:12
295 查看
#connect to db
sqlite_conn = sqlite3.connect("image_link.db")
sqlite_conn.text_factory = str
#get cursor
cursor = sqlite_conn.cursor()
#create table
cursor.execute('''create table if not exists sexygirl(id integer primary key,urlstring text)''')
fh = open("beauty.txt")
index = 0
for line in fh.readlines():
if len(line):
index = index +1;
dic = (line,);
cursor.execute("select * from sexygirl where urlstring = ?",dic)
rows = cursor.fetchone()
if rows:
{}
else:
cursor.execute("insert into sexygirl values(?,?)",(index,line))
sqlite_conn.commit()
sqlite_conn.close()
sqlite_conn = sqlite3.connect("image_link.db")
sqlite_conn.text_factory = str
#get cursor
cursor = sqlite_conn.cursor()
#create table
cursor.execute('''create table if not exists sexygirl(id integer primary key,urlstring text)''')
fh = open("beauty.txt")
index = 0
for line in fh.readlines():
if len(line):
index = index +1;
dic = (line,);
cursor.execute("select * from sexygirl where urlstring = ?",dic)
rows = cursor.fetchone()
if rows:
{}
else:
cursor.execute("insert into sexygirl values(?,?)",(index,line))
sqlite_conn.commit()
sqlite_conn.close()
相关文章推荐
- python从sqlite读取并显示数据的方法
- Python实现读取TXT文件数据并存进内置数据库SQLite3的方法
- python从sqlite读取并显示数据的方法
- Python读取SQLite文件数据
- Python读取和处理文件后缀为".sqlite"的数据文件
- Python读取和处理文件后缀为.sqlite的数据文件(实例讲解)
- Python读取.mat文件 (脑电数据)
- python读取文本数据到矩阵(用于scikit-learn输入)
- 用python读取cifar-10与cifar-100图像数据
- python hbase读取数据发送kafka
- 使用SQLiteOpenHelper插入数据到数据库并读取数据库中的内容
- python读取.txt文件数据和将数据写入文件.txt
- Delphi中使用python脚本读取Excel数据
- 【Python_Demo_2】使用Python连续(批量)读取图片数据的Demo
- python post数据后读取cookie ,session
- python matplotlib从文件中读取数据绘制散点图
- 利用Python数据可视化工具plotly从数据库读取数据制作本地图表应用实例
- android数据存储读取4:Sqlite(CRUD)
- python实现正弦+余弦图+csv文件数据读取
- python mysqldb 读取数据存储到excel中