fastmonkeys / stellar

Fast database snapshot and restore tool for development
MIT License
3.86k stars 119 forks source link

stellar init mysql "no module named MySQLDb" #15

Closed uptownhr closed 10 years ago

uptownhr commented 10 years ago
uptown@ubuntu ~/domains/processing[uploads_transfer*]$ stellar init
Please enter the url for your database.

For example:
PostreSQL: postgresql://localhost:5432/
MySQL: mysql+pymysql://root@localhost/: 
Please enter the url for your database.

For example:
PostreSQL: postgresql://localhost:5432/
MySQL: mysql+pymysql://root@localhost/: mysql://root@localhost
Traceback (most recent call last):
  File "/usr/local/bin/stellar", line 9, in <module>
    load_entry_point('stellar==0.3.1', 'console_scripts', 'stellar')()
  File "/usr/local/lib/python2.7/dist-packages/stellar/command.py", line 225, in main
    stellar()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 572, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 552, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 893, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 744, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 388, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/stellar/command.py", line 163, in init
    engine = create_engine(url, echo=False)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/__init__.py", line 346, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 74, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/connectors/mysqldb.py", line 64, in dbapi
    return __import__('MySQLdb')
ImportError: No module named MySQLdb
Teemu commented 10 years ago

I don't know much about MySQL drivers (I'm more of a PostgreSQL guy) but try installing the libraries for MySQL (I think it was python-mysql in Ubuntu?). You can also try using the pure Python driver if you use mysql+pymysql:// as the driver url.

wonderfool commented 10 years ago

On CentOS and OSX it was pip install mysql-python. You may need to apt-get libmysqlclient-dev first as well (I'm not sure about this though).

jruzafa commented 10 years ago

i has the same problem, but fixed with install mysql library for python:

Teemu commented 10 years ago

Closing because I added a better error message for this in https://github.com/fastmonkeys/stellar/commit/c9bfba235dc0775b9cae89ea54b2b3125e6e5534 .