Skip to content

Commit 3cd925c

Browse files
committed
Fallback to pymysql
1 parent 3a6189f commit 3cd925c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Limitations
2222
-----------
2323

2424
Torndb does not support Python 3, or any database drivers other than
25-
`MySQLdb`.
25+
`MySQLdb` or `pymysql`.
2626

2727
Installation
2828
------------

torndb.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
import MySQLdb.converters
3434
import MySQLdb.cursors
3535
except ImportError:
36-
# If MySQLdb isn't available this module won't actually be useable,
37-
# but we want it to at least be importable on readthedocs.org,
38-
# which has limitations on third-party modules.
39-
if 'READTHEDOCS' in os.environ:
40-
MySQLdb = None
41-
else:
42-
raise
36+
try:
37+
import pymysql as MySQLdb
38+
except ImportError:
39+
# If MySQLdb isn't available this module won't actually be useable,
40+
# but we want it to at least be importable on readthedocs.org,
41+
# which has limitations on third-party modules.
42+
if 'READTHEDOCS' in os.environ:
43+
MySQLdb = None
44+
else:
45+
raise
4346

4447
version = "0.3"
4548
version_info = (0, 3, 0, 0)

0 commit comments

Comments
 (0)