Can anyone tell me where I have done wrong?
my code:
import csv
import sqlite3
import os
import subprocess
import glob
#Connect to database
conn = sqlite3.connect("Mpeg_editor_Final.db")
try:
conn.execute("drop table Mpeg_editor_Final")
conn.execute("drop table edited")
conn.execute("drop table ffmpeg")
except sqlite3.OperationalError, e:
print e.message
#CREATE table in databse
conn.execute("PRAGMA foreign_keys = 1")
conn.execute("CREATE TABLE Mpeg_editor_Final (fileName VARCHAR(120), fileType VARCHAR(120), fileFolder VARCHAR(120))")
conn.execute("CREATE TABLE edited (fileName VARCHAR(120), fileType VARCHAR(120), fileFolder VARCHAR(120))")
conn.execute("CREATE TABLE ffmpeg (fileName VARCHAR(120), fileType VARCHAR(120), fileFolder VARCHAR(120))")
#mpegEditorFinal file location
mpegEditorFinal = 'C:Mpeg_editor_Final'
#list all folders and file in Mpeg_editor_Final
mpegEditorFinaldirs = os.listdir(mpegEditorFinal)
# tell file's extensions
for i in mpegEditorFinaldirs:
mpegEditorFinalext = os.path.splitext(i)
#find current path
for x in mpegEditorFinaldirs:
mpegEditorFinalpath = os.path.dirname(x)
#To write information into the Mpeg_editor_final table
conn.executemany("INSERT INTO Mpeg_editor_Final (fileName, fileType, fileFolder) VALUES (?,?,?);", [mpegEditorFinaldirs , mpegEditorFinalext , mpegEditorFinalpath,])
conn.commit()
The error message:
Message File Name Line Position
Traceback
<module> C:Mpeg_editor_Finaldatabase.py 36
ProgrammingError: Incorrect number of bindings supplied. The current statement uses 3, and there are 16 supplied.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…