我在 MySQL 表中有数据,我想将其复制到 PostgreSQL 表中。一切正常,除非 MySQL 包含带有"
和/或的字符串'
例如: MySQL 中的数据:
当我运行我的代码时,我得到:
ProgrammingError: ERROR: syntax error at or near "t"
(不能的 t)
这是我的代码:
postgre = pg.connect(dbname=DB,user=USR,passwd=PASSWD,host=HOST, port=PORT)
crs = db_remote.cursor(MySQLdb.cursors.DictCursor)
crs.execute ("""select post_id, post_excerpt from tabl""")
data = crs.fetchall ()
for row in data :
postgre.query("""INSERT INTO importfrommysql(id,message)
VALUES ('%s','%s')"""%(row["post_id"],row["post_excerpt"]))
连接pg.connect
来自PygreSQL
包装。我能做些什么?是否可以按原样获取文本?或者唯一的解决方案是在插入之前删除所有"
/ '
?