我有一个从SQL数据库创建.csv文件以在另一个程序中使用的功能。我需要能够对数据库中的数百个不同样本运行此功能。
导入sqlite3 导入csv 导入操作系统 conn = sqlite3.connect(“ UTS_6.db”) c = conn.cursor()
def getit(X): X
data = c.execute(
"SELECT x,y, CAST( (direction*180/3.142)as INT),CAST(quality*100 as INT) from UTS_6_fingerprints where finger like ? ",
(X,))
for row in data:
print row
csv_path = "X.csv"
with open('X.csv', "w") as csv_file:
writer = csv.writer(csv_file, delimiter= " ")
for row in data:
writer.writerows([row])
os.rename ("X.csv",X)
getit('lt_94')