DailyNotes icon indicating copy to clipboard operation
DailyNotes copied to clipboard

[Question] dailynotes configuration

Open duchenpaul opened this issue 3 years ago • 6 comments

  1. 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
  1. Example for /app/config, could you please give us some examples about the config, is config a file or a dir?
  2. 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?

duchenpaul avatar May 10 '21 01:05 duchenpaul

  1. Instead of DB_SERVER_HOST you should be using DATABASE_URI.
  2. It is a directory, keeps some config stuff setup.'
  3. No, it uses sqlalchemy to interface with the databases, you don't need to do anything else.

m0ngr31 avatar May 10 '21 03:05 m0ngr31

  1. Sorry that was my fault
  2. 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.
  3. 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

duchenpaul avatar May 10 '21 05:05 duchenpaul

MySQL support

  1. Code: add PyMySQL into requirements.txt
  2. 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

  1. Code: add psycopg2 into requirements.txt
  2. Doc: Advise user in readme to use below connect string as their DATABASE_URI
postgresql+psycopg2://user:pass@host/dbname?client_encoding=utf8

duchenpaul avatar May 10 '21 05:05 duchenpaul

Need to specify the length of varchar column to make mysql working

duchenpaul avatar May 10 '21 13:05 duchenpaul

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

m0ngr31 avatar May 10 '21 14:05 m0ngr31

PR submited

duchenpaul avatar May 10 '21 15:05 duchenpaul