2011. 12. 14.

insert file list into sqlite-db table by python


~                                                                                                        import os,sqlite3

con = sqlite3.connect("sqlite_test.db")
cur = con.cursor()

flist = os.listdir("/Users/path/")
for ff in flist:
        f = (ff,)
        cur.execute('insert into tbl_local (vcpath) values(?)' , f )  # watch out, question-mark.  there is no quotation mark
con.commit()
con.close()

댓글 없음:

댓글 쓰기