Skip to content
Snippets Groups Projects
Commit 1645e52a authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Change to postgresql 12

parent 6159e5e8
No related branches found
No related tags found
No related merge requests found
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
script_location = migrations script_location = migrations
# script_location = cachedb_migrations # script_location = cachedb_migrations
# change this to run migrations from the command line # change this to run migrations from the command line
sqlalchemy.url = mysql+pymysql://compendium:compendium321@localhost/compendium sqlalchemy.url = postgresql://compendium:compendium321@localhost:65000/compendium
...@@ -31,9 +31,9 @@ def session_scope( ...@@ -31,9 +31,9 @@ def session_scope(
session.close() session.close()
def mysql_dsn(db_username, db_password, db_hostname, db_name, port=3306): def postgresql_dsn(db_username, db_password, db_hostname, db_name, port=5432):
return (f'mysql+pymysql://{db_username}:{db_password}' return (f'postgresql://{db_username}:{db_password}'
f'@{db_hostname}:{port}/{db_name}?charset=utf8mb4') f'@{db_hostname}:{port}/{db_name}')
def init_db_model(dsn): def init_db_model(dsn):
......
...@@ -29,9 +29,9 @@ def upgrade(dsn, migrations_directory=DEFAULT_MIGRATIONS_DIRECTORY): ...@@ -29,9 +29,9 @@ def upgrade(dsn, migrations_directory=DEFAULT_MIGRATIONS_DIRECTORY):
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
upgrade(db.mysql_dsn( upgrade(db.postgresql_dsn(
db_username='compendium', db_username='compendium',
db_password='compendium321', db_password='compendium321',
db_hostname='localhost', db_hostname='localhost',
db_name='compendium', db_name='compendium',
port=3306)) port=65000))
{ {
"SQLALCHEMY_DATABASE_URI": "mysql+pymysql://compendium:compendium321@localhost/compendium" "SQLALCHEMY_DATABASE_URI": "postgresql://compendium:compendium321@localhost:65000/compendium"
} }
version: '3.1'
services: services:
mysql: postgres:
restart: unless-stopped image: postgres:12
container_name: mysql-compendium environment:
environment: POSTGRES_DB: compendium
MYSQL_ALLOW_EMPTY_PASSWORD: "no" POSTGRES_USER: compendium
MYSQL_DATABASE: compendium POSTGRES_PASSWORD: compendium321
MYSQL_PASSWORD: compendium321 restart: unless-stopped
MYSQL_ROOT_PASSWORD: compendium321 hostname: postgres
MYSQL_USER: compendium ports:
volumes: - "65000:5432"
- ./build/mysql_logs:/var/log/ volumes:
- ./build/mysql_data:/var/lib/mysql/ - ./build/db:/var/lib/postgresql
image: mysql:8 \ No newline at end of file
command: mysqld --general-log=1 --general-log-file=/var/log/mysql.log
ports:
- 3306:3306
...@@ -15,7 +15,7 @@ setup( ...@@ -15,7 +15,7 @@ setup(
'flask-cors', 'flask-cors',
'SQLAlchemy', 'SQLAlchemy',
'alembic', 'alembic',
'PyMySQL', 'psycopg2-binary',
'cryptography', 'cryptography',
], ],
include_package_data=True, include_package_data=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment