kennethreitz / records

SQL for Humans™
https://pypi.python.org/pypi/records/
ISC License
7.16k stars 574 forks source link

Error when using Python3 and MySQL #121

Closed leafonsword closed 6 years ago

leafonsword commented 6 years ago

records' default mysql driver is MySQLdb, but MySQLdb doesn't support python3, how about support PyMySQL?

>>> import records
>>> db = records.Database('mysql://...')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    db = records.Database('mysql://...')
  File "/usr/local/miniconda2/envs/py3_env/lib/python3.6/site-packages/records.py", line 242, in __init_
_
    self._engine = create_engine(self.db_url, **kwargs)
  File "/usr/local/miniconda2/envs/py3_env/lib/python3.6/site-packages/sqlalchemy/engine/__init__.py", l
ine 391, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/local/miniconda2/envs/py3_env/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py",
 line 80, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/usr/local/miniconda2/envs/py3_env/lib/python3.6/site-packages/sqlalchemy/dialects/mysql/mysqldb
.py", line 110, in dbapi
    return __import__('MySQLdb')
ModuleNotFoundError: No module named 'MySQLdb'
Kilo59 commented 6 years ago

What is the goto driver for MySQL nowadays?

leafonsword commented 6 years ago

@Kilo59 PyMySQL(pure python implemented)and mysqlclient(a fork of MySQL-python. It adds Python 3 support and fixed many bugs). When I install mysqlclient, since mysqlclient is a fork of MySQL-python, records works ok, haha~

mouday commented 6 years ago

so we will install mysqlclient, not install MySQL-python

pip install mysqlclient

mygood!!! author should tell us