i encounter error when i'm trying insert values table. here's code:
def tsx_insert(self, d_list): item in d_list: query = """ insert ignore tsx_first_insert(protocollo,procedura,oggetto,priorita, tipo_richiesta,sottotipo_richiesta,emergenza, richiesta,uo_richiedente,autore,scadenza_sla) values(%(protocollo)s,%(procedura)s,%(oggetto)s,%(priorita)s,%(tipo_richiesta)s, %(sottotipo_richiesta)s,%(emergenza)s,%(richiesta)s,%(uo_richiedente)s, %(autore)s,%(scadenza_sla)s)""" values = item.values() self.exec_query(query,values)
and here 'exec_query' function:
def exec_query(self, query, params): try: if self.connected none: self.connect() self.cursor = self.connected.cursor() self.cursor.connection.autocommit(true) self.cursor.execute(query) if self.cursor.description: self.description = [d[0] d in self.cursor.description] self.rows = self.cursor.rowcount self.sql_result = self.cursor.fetchall() except mysqldb.error, e: logging.error('error {0}: {1}'.format(e.args[0], e.args[1])) finally: self.cursor.close()
the error is: "error 1064: have error in sql syntax; check manual corresponds mariadb server version right syntax use near '%(protocollo)s,%(procedura)s,%(oggetto)s,%(priorita)s,%(tipo_richiesta)s, ' @ line 4"
i can't figure out problem. thank in advance help.
you forgot mention params
dictionary in self.cursor.execute()
method call, parameter strings left in place rather substituted.
try
self.cursor.execute(query, params)
Comments
Post a Comment