尚未解决Python3 Pymysql语法错误

时间:2018-07-14 17:29:10

标签: python mysql error-handling syntax pymysql

尝试大量导入,使用python将图像标题放入mysql数据库。

错误:pymysql.err.ProgrammingError:(1064,“您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以在'','object','30.0附近使用正确的语法','1','2018-05-05 07:51:40.489172','2.9776451503037054','0'在第4行“)

输入:

def new_import(self):
    print("Importing image data...")
    with cnx.cursor() as cur:
        add_image_data = (
            """INSERT INTO image(
            filename, object, type, exptime, accum, starttime, ra, decl,
            hangle, airmass, state, filter, propidx)
            VALUES('{}', {}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}',
            '{}', '{}', '{}';)""".format(
                fname, hdr.object, hdr.imagetyp, hdr.exptime, hdr.accum,
                hdr.dateobs, img.ra, img.dec, img.ha, hdr.airmass, state,
                hdr.filt, img.propidx))
        cur.execute(add_image_data)
    with cnx.cursor() as cur:
        add_datastat_data = (
            """INSERT INTO datastat(dir, obsdate, site, tel, camera,
            state, completed, nobj, nbias, ndark, nflat)
            VALUES('{}','{}', '{}', '{}', '{}','{}', '{}', '{}', '{}', '{}',
            '{}');
            ".format(path, dateobs, observat, telescop, camseri, state,
            headvers, nobj, nbias, ndark, nflat))""")
        cur.execute(add_datastat_data)

0 个答案:

没有答案