-
Notifications
You must be signed in to change notification settings - Fork 443
Closed
Description
I'm trying this only on version 1.3.7 because i'm unable to run newer version (getting 'undefined symbol: OPENSSL_add_all_algorithms_noconf' after import, MariaDB 10.1), one i'm using was installed as original package from Debian 9.
When using SSCursor or SSDictCursor, i'm getting IntegrityError on 'execute' command AND the same IntegrityError error also on cursor close(). 100% reproducable, also see few comments in the code:
import MySQLdb
db_conn = MySQLdb.connect(host="localhost", user="user", passwd="password", db="database")
db_conn.autocommit(True)
db_curr = db_conn.cursor(MySQLdb.cursors.SSDictCursor)
# uncoment this to 'fix' the error
#db_curr = db_conn.cursor()
try:
db_curr.execute("CREATE TABLE `test` (test VARCHAR(255) UNIQUE) ENGINE=InnoDB")
except:
pass
# this is interesting, the error only appears if there is any SELECT before
db_curr.execute("SELECT * FROM `test`")
mysql_result = db_curr.fetchall()
try:
db_curr.execute("INSERT INTO `test` SET test='test'")
db_curr.execute("INSERT INTO `test` SET test='test'")
except MySQLdb.IntegrityError:
print "catched IntegrityError"
db_curr.close()
db_conn.close()
Output:
catched IntegrityError
Traceback (most recent call last):
File "test_db.py", line 19, in <module>
db_curr.close()
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 91, in close
while self.nextset():
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 138, in nextset
self.fetchall()
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 474, in fetchall
r = self._fetch_row(0)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 351, in _fetch_row
return self._result.fetch_row(size, self._fetch_type)
_mysql_exceptions.IntegrityError: (1062, "Duplicate entry 'test' for key 'test'")
Metadata
Metadata
Assignees
Labels
No labels