Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] dailynotes configuration #32

Open
duchenpaul opened this issue May 10, 2021 · 6 comments
Open

[Question] dailynotes configuration #32

duchenpaul opened this issue May 10, 2021 · 6 comments

Comments

@duchenpaul
Copy link

  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?
@m0ngr31
Copy link
Owner

m0ngr31 commented May 10, 2021

  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.

@duchenpaul
Copy link
Author

  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
Copy link
Author

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
Copy link
Author

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

@m0ngr31
Copy link
Owner

m0ngr31 commented May 10, 2021

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

@duchenpaul
Copy link
Author

PR submited

duchenpaul pushed a commit to duchenpaul/DailyNotes that referenced this issue May 10, 2021
duchenpaul pushed a commit to duchenpaul/DailyNotes that referenced this issue May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants