diff --git a/compendium_v2/alembic.ini b/compendium_v2/alembic.ini index 734a7c316cc26c202ff447b5cab6594a21a618a4..2145863baa95551a588dd229ee525abd06f32742 100644 --- a/compendium_v2/alembic.ini +++ b/compendium_v2/alembic.ini @@ -7,4 +7,4 @@ script_location = migrations # script_location = cachedb_migrations # 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 diff --git a/compendium_v2/db/__init__.py b/compendium_v2/db/__init__.py index e913621db04950e9e6a28c94f8bb82b449db9ba3..2a07293a14277e62923a2abcbdc449204e661af8 100644 --- a/compendium_v2/db/__init__.py +++ b/compendium_v2/db/__init__.py @@ -31,9 +31,9 @@ def session_scope( session.close() -def mysql_dsn(db_username, db_password, db_hostname, db_name, port=3306): - return (f'mysql+pymysql://{db_username}:{db_password}' - f'@{db_hostname}:{port}/{db_name}?charset=utf8mb4') +def postgresql_dsn(db_username, db_password, db_hostname, db_name, port=5432): + return (f'postgresql://{db_username}:{db_password}' + f'@{db_hostname}:{port}/{db_name}') def init_db_model(dsn): diff --git a/compendium_v2/migrations/migration_utils.py b/compendium_v2/migrations/migration_utils.py index c2af5cde365518433598a4cca29e18365d8f4ff1..3b29b540ed3382d8da1416a70d5bf9be5a01e1bc 100644 --- a/compendium_v2/migrations/migration_utils.py +++ b/compendium_v2/migrations/migration_utils.py @@ -29,9 +29,9 @@ def upgrade(dsn, migrations_directory=DEFAULT_MIGRATIONS_DIRECTORY): if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) - upgrade(db.mysql_dsn( + upgrade(db.postgresql_dsn( db_username='compendium', db_password='compendium321', db_hostname='localhost', db_name='compendium', - port=3306)) + port=65000)) diff --git a/config-example.json b/config-example.json index d168df4432176fb9345e45ad429ee896f7088665..4f04692c45c28efdc65bb2f8f920683c601cc816 100644 --- a/config-example.json +++ b/config-example.json @@ -1,3 +1,3 @@ { - "SQLALCHEMY_DATABASE_URI": "mysql+pymysql://compendium:compendium321@localhost/compendium" + "SQLALCHEMY_DATABASE_URI": "postgresql://compendium:compendium321@localhost:65000/compendium" } diff --git a/docker-compose.yml b/docker-compose.yml index de0a388ae2e432a1981ebec624a3bfedef4a6d04..8ac10f23829d11b9a0553ef7945d350221199bf9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,15 @@ +version: '3.1' + services: - mysql: - restart: unless-stopped - container_name: mysql-compendium - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: "no" - MYSQL_DATABASE: compendium - MYSQL_PASSWORD: compendium321 - MYSQL_ROOT_PASSWORD: compendium321 - MYSQL_USER: compendium - volumes: - - ./build/mysql_logs:/var/log/ - - ./build/mysql_data:/var/lib/mysql/ - image: mysql:8 - command: mysqld --general-log=1 --general-log-file=/var/log/mysql.log - ports: - - 3306:3306 + postgres: + image: postgres:12 + environment: + POSTGRES_DB: compendium + POSTGRES_USER: compendium + POSTGRES_PASSWORD: compendium321 + restart: unless-stopped + hostname: postgres + ports: + - "65000:5432" + volumes: + - ./build/db:/var/lib/postgresql \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 378dff7a389ac5c9310e94656bc3e53a4dd49da3..704282cf5576b0fa4d2f75484b90491bd99aa7ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ alembic jsonschema flask flask-cors -PyMySQL +psycopg2-binary cryptography SQLAlchemy pytest diff --git a/setup.py b/setup.py index d8ca4882dce5fd19d9f6a6bd26de6b5d42a9f98c..250b9be055fd80531ab79396896c20c51817c6b4 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( 'flask-cors', 'SQLAlchemy', 'alembic', - 'PyMySQL', + 'psycopg2-binary', 'cryptography', ], include_package_data=True,