从 Access .mdb 表中插入选定的记录/行时,我Syntax error in INSERT INTO statement. (-3502)
在此代码块的第 23 行找到了一个“”。
我想要发生的是
- 创建一个表'65001'
- 从表“LMR_Combined”中选择前 65000 行
- 将这些选定的行插入到新创建的“65001”表中。
这个 INSERT INTO 语句中有什么语法错误阻止了成功执行?
import pyodbc
DBFile = r'C:\Python27\FCC_Processing\LMR Combined.mdb'
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ='+DBFile)
cursor = conn.cursor()
# Creates a table "65001" in the MDB that matches the schema of table "LMR_Combined"
string = "CREATE TABLE 65001(OBJECTID integer, Unique_ID varchar(255), LICENSEE_NAME varchar(255))"
cursor.execute(string)
# Selects 65000 records from table "LMR_Combined"
cursor.execute('select OBJECTID, Unique_ID, LICENSEE_NAME from LMR_Combined where OBJECTID > 0 and OBJECTID < 65001')
row = cursor.fetchone()
# For debugging, print a line
if row:
print row
# Inserts the 65000 rows into the new table "65001"
cursor.execute('insert OBJECTID, Unique_ID, LICENSEE_NAME into 65001')
conn.commit()
提前致谢