From b81a8214805c23df67ae4bb1cd48f154e37ad71d Mon Sep 17 00:00:00 2001 From: Gusev Anton <gusev_aa@groupbwt.com> Date: Mon, 17 Jun 2019 15:21:14 +0300 Subject: [PATCH] add DB_CHARSET params to settings --- .gitignore | 3 ++- src/.env.example | 1 + src/alembic.ini.example | 2 +- src/settings.py | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 512940a..05bb782 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ alembic.ini __pycache__ *.json src/spiders/Test*.py -*.log \ No newline at end of file +*.log +statistics.txt \ No newline at end of file diff --git a/src/.env.example b/src/.env.example index b9541b7..026c98a 100644 --- a/src/.env.example +++ b/src/.env.example @@ -6,6 +6,7 @@ DB_PORT=3306 DB_DATABASE=database DB_USERNAME=username DB_PASSWORD=secret +DB_CHARSET=utf8mb4 ### MAIL CONFIG MAIL_FROM = 'example@example.com' diff --git a/src/alembic.ini.example b/src/alembic.ini.example index fe3f6a7..62b4a90 100644 --- a/src/alembic.ini.example +++ b/src/alembic.ini.example @@ -36,7 +36,7 @@ script_location = database # output_encoding = utf-8 # sqlalchemy.url = driver://user:pass@host:port/dbname -sqlalchemy.url = mysql+pymysql://user:password@localhost/databasename +sqlalchemy.url = mysql+pymysql://user:password@localhost/databasename?utf8mb4 # Logging configuration diff --git a/src/settings.py b/src/settings.py index 7880245..519c03d 100644 --- a/src/settings.py +++ b/src/settings.py @@ -2,6 +2,7 @@ import logging from dotenv import load_dotenv import os + true_list = ['True', 'true', 'TRUE', 1, '1'] load_dotenv() @@ -103,13 +104,15 @@ DB_PASSWORD = os.getenv('DB_PASSWORD') DB_HOST = os.getenv('DB_HOST') DB_PORT = int(os.getenv('DB_PORT')) DB_DATABASE = os.getenv('DB_DATABASE') -CONNECTION_STRING = "{drivername}://{user}:{passwd}@{host}:{port}/{db_name}?charset=utf8".format( +DB_CHARSET = os.getenv('DB_CHARSET') +CONNECTION_STRING = "{drivername}://{user}:{passwd}@{host}:{port}/{db_name}?charset={db_charset}".format( drivername=DB_CONNECTION, user=DB_USERNAME, passwd=DB_PASSWORD, host=DB_HOST, port=str(DB_PORT), db_name=DB_DATABASE, + db_charset=DB_CHARSET, ) # Logger config -- GitLab