DailyNotes
DailyNotes copied to clipboard
[Question] dailynotes configuration
- Set up DATABASE_URI, How to set up database, I tried to use below config to set up mysql database, but it still creates itself a sqlite.
version: "2"
services:
dailynotes:
image: m0ngr31/dailynotes:version-1.0-beta6
container_name: dailynotes
volumes:
- {{ dailynotes_data_dir }}:/app/config
environment:
- DB_SERVER_HOST=mysql://pi:[email protected]/dailynotes
ports:
- {{ http_port }}:5000
restart: always
- Example for
/app/config
, could you please give us some examples about the config, is config a file or a dir? - Does it need database drives to install to use mysql? what if I would like to use pgsql, do I need to pip install psycopg2, and how? Just like
docker exec dailynote pip install psycopg2
?
- Instead of
DB_SERVER_HOST
you should be usingDATABASE_URI
. - It is a directory, keeps some config stuff setup.'
- No, it uses sqlalchemy to interface with the databases, you don't need to do anything else.
- Sorry that was my fault
- I saw the readme, saying that you can put config files inside that config dir, so you dont have to pass in via docker cmd. I wonder how.
- I know you are using sqlalchemy, but sqlalchemy needs drive to talk to other databases, I see it goes wrong if you use mysql url. Reference for sqlchemy here, same senarios applied to pgsql as well, for this issue, I would suggest you include popular pip packages for databases in dockerfile.
error log:
...
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
[2021-05-10 04:41:44 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2021-05-10 04:41:44 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2021-05-10 04:41:44 +0000] [1] [INFO] Using worker: sync
[2021-05-10 04:41:44 +0000] [14] [INFO] Booting worker with pid: 14
MySQL support
- Code: add
PyMySQL
intorequirements.txt
- Doc: Advise user in readme to use below connect string as their
DATABASE_URI
mysql+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4
PgSQL support
- Code: add
psycopg2
intorequirements.txt
- Doc: Advise user in readme to use below connect string as their
DATABASE_URI
postgresql+psycopg2://user:pass@host/dbname?client_encoding=utf8
Need to specify the length of varchar column to make mysql working
Okay, that's good info, thanks! I haven't had someone actually try MySQL or Postgres yet I guess! 😄 I'll get an update out soon
PR submited