Nextdoor / ndscheduler

A flexible python library for building your own cron-like system, with REST APIs and a Web UI.
BSD 2-Clause "Simplified" License
1.08k stars 202 forks source link

Not able to use MySQL #93

Open SatoshiMD opened 3 years ago

SatoshiMD commented 3 years ago

When I override DB setting, I got error. See below

settings.py DATABASE_CLASS = 'ndscheduler.core.datastore.providers.mysql.DatastoreMySQL' DATABASE_CONFIG_DICT = { 'user': 'username', 'password': '', 'hostname': 'localhost', 'port': 3306, 'database': 'scheduler' }

Error app_1 | Traceback (most recent call last): app_1 | File "scheduler.py", line 46, in <module> app_1 | SampleJobServer.run() app_1 | File "/usr/local/lib/python3.6/site-packages/ndscheduler/server/server.py", line 83, in run app_1 | cls.singleton = cls(scheduler_manager.SchedulerManager.get_instance()) app_1 | File "/usr/local/lib/python3.6/site-packages/ndscheduler/core/scheduler_manager.py", line 22, in get_instance app_1 | cls.instance = cls() app_1 | File "/usr/local/lib/python3.6/site-packages/ndscheduler/core/scheduler_manager.py", line 27, in __init__ app_1 | 'default': utils.get_datastore_instance() app_1 | File "/usr/local/lib/python3.6/site-packages/ndscheduler/utils.py", line 106, in get_datastore_instance app_1 | database_class = import_from_path(settings.DATABASE_CLASS) app_1 | File "/usr/local/lib/python3.6/site-packages/ndscheduler/utils.py", line 31, in import_from_path app_1 | return getattr(module, components[-1]) app_1 | AttributeError: module 'ndscheduler.core.datastore.providers.mysql' has no attribute 'DatastoreMySQL'

robnardo commented 3 years ago

I was also having this issue. I found that the reference to DATABASE_CLASS should be the following (notice the case of the class name). DatastoreMySQL should be DatastoreMysql

ndscheduler.core.datastore.providers.mysql.DatastoreMysql

I found the answer by trying to import the module and seeing what VS Code intellisense came up with. Not sure why I need to do this? I am using the version from PyPi which is 0.3.0 - is this not the latest version?

Update: Looks like file was deleted then added again with a different case for MySQL. This is the committ..

https://github.com/Nextdoor/ndscheduler/commit/06b4a9237031e04ccce19075636369ab5e4a8297 (search the page for "mysql")

Is there a pipeline to get latest version of Ndscheduler to PyPi.org ?

Hope this helps :)