![]() ![]() 'INSERT INTO spectra (PathCol, DateCol) VALUES (?, CURRENT_DATE)', In addition, it would be good practice to get out of the habit of building SQL statements as strings and instead to use parameterized queries: cur.execute( The SQLite syntax for obtaining the current date is CURRENT_DATE (CURRENT_TIME and CURRENT_TIMESTAMP are also available): INSERT INTO spectra VALUES ('C:\users\python\target\Bertil.spc', CURRENT_DATE) The value of the query-variable as printed is INSERT INTO spectra VALUES ('C:\users\python\target\Bertil.spc',SELECT date('now')) OperationalError: near "SELECT": syntax error ![]() It crashes on the line "cur.execute(query)", rendering this error: Traceback (most recent call last):įile "C:/Users/Python/logspc2.py", line 27, in Query="INSERT INTO spectra VALUES ('" + newpath + "',SELECT date('now'))" Newpath=os.path.normpath(os.path.join(dest,mfile)) Oldpath=os.path.normpath(os.path.join(src,mfile)) Src=os.path.normpath(r'C:\users\python\nonpython')ĭest=os.path.normpath(r'C:\users\python\target') (shortname, extension) = os.path.splitext(filename) I do, however, have great problems with putting together and executing the SQL-query that inserts them into the database. I'm making a program that is suppoused to move files and save their new paths in a database. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |