Note that there are some explanatory texts on larger screens.

plurals
  1. POConnector/python executemany NoneType
    text
    copied!<p>I have a little problem with Connector/python executing insert query. </p> <p>I have function to insert data into database. Argument data is list of tuples: [(2652884, '<a href="http://www.example.com/" rel="nofollow">http://www.example.com/</a>', '5.0.5.239', 1), ..... ]</p> <pre><code>def insert_url(self, data): query = "INSERT INTO `sp_urls` (`parent_id`, `url`, `version`, `hits`) VALUES (%d, %s, %s, %d) ON DUPLICATE KEY UPDATE url=url" try: cursor = self.__cnx.cursor() cursor.executemany(query, data) except (mysql.connector.errors.IntegrityError) as err: print("Query syntax error:", err, file=sys.stderr) except (mysql.connector.errors.ProgrammingError) as err: print("Programming err:{0}".format(err)) finally: cursor.close() </code></pre> <p>The query itself works, in self.__cnx is initialized connection. Here's the traceback:</p> <pre><code> File "sdi/database/DbValidator.py", line 91, in process_records self.__driver.insert_url(urldata) File "/home/david/workspace/stickydi/sdi/database/MySQLDriver.py", line 87, in insert_url cursor.executemany(query, data) File "/usr/lib/python3/dist-packages/mysql/connector/cursor.py", line 492, in executemany return self._batch_insert(operation,seq_params) File "/usr/lib/python3/dist-packages/mysql/connector/cursor.py", line 428, in _batch_insert fmt = m.group(1).encode(self._connection.charset) AttributeError: 'NoneType' object has no attribute 'group' </code></pre> <p>I have one very similar method, and it works OK, I just can't see, why does executemany( ) goes wrong.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload