mirror of
https://github.com/correl/dejavu.git
synced 2024-11-27 11:09:51 +00:00
Switched back to MySQLdb for better support of executemany.
This commit is contained in:
parent
ab2cf9d58b
commit
bed11f3de7
2 changed files with 11 additions and 10 deletions
|
@ -2,8 +2,8 @@ from __future__ import unicode_literals
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import Queue
|
import Queue
|
||||||
|
|
||||||
import pymysql
|
import MySQLdb as mysql
|
||||||
import pymysql.cursors
|
import MySQLdb.cursors
|
||||||
|
|
||||||
|
|
||||||
def cursor_factory(**factory_options):
|
def cursor_factory(**factory_options):
|
||||||
|
@ -26,18 +26,18 @@ class Cursor(object):
|
||||||
"""
|
"""
|
||||||
_cache = Queue.Queue(maxsize=5)
|
_cache = Queue.Queue(maxsize=5)
|
||||||
|
|
||||||
def __init__(self, cursor_type=pymysql.cursors.DictCursor, **options):
|
def __init__(self, cursor_type=mysql.cursors.DictCursor, **options):
|
||||||
super(Cursor, self).__init__()
|
super(Cursor, self).__init__()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = self._cache.get_nowait()
|
conn = self._cache.get_nowait()
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
conn = pymysql.connect(**options)
|
conn = mysql.connect(**options)
|
||||||
|
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
self.cursor_type = cursor_type
|
self.cursor_type = cursor_type
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(slf):
|
||||||
self.cursor = self.conn.cursor(self.cursor_type)
|
self.cursor = self.conn.cursor(self.cursor_type)
|
||||||
return self.cursor
|
return self.cursor
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
|
|
||||||
|
from MySQLdb.cursors import Cursor
|
||||||
|
|
||||||
class Database(object):
|
class Database(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Database, self).__init__()
|
super(Database, self).__init__()
|
||||||
|
@ -281,7 +283,6 @@ class SQLDatabase(Database):
|
||||||
|
|
||||||
values.
|
values.
|
||||||
"""
|
"""
|
||||||
from pymysql.cursors import Cursor
|
|
||||||
# Create a dictionary of hash => offset pairs for later lookups
|
# Create a dictionary of hash => offset pairs for later lookups
|
||||||
mapper = {}
|
mapper = {}
|
||||||
for hash, (_, offset) in hashes:
|
for hash, (_, offset) in hashes:
|
||||||
|
|
Loading…
Reference in a new issue