From ae2f7876a5daeace0c49cadfe010af6143158126 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Sat, 14 Sep 2024 15:24:38 +0200 Subject: [PATCH] Add database drivers as optional dependencies --- examples/config.py | 3 +++ pdm.lock | 21 ++++++++++++++++----- pyproject.toml | 7 ++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/examples/config.py b/examples/config.py index ae122ff..f792cc1 100644 --- a/examples/config.py +++ b/examples/config.py @@ -7,6 +7,9 @@ from pathlib import Path SQLALCHEMY_DATABASE_URI = "postgresql+psycopg:///schilder2000" +# SQLALCHEMY_DATABASE_URI = "sqlite:///schilder2000.db" # Relative to instance directory +# SQLALCHEMY_DATABASE_URI = "mysql:///schilder2000" + # To generate a secret key: # % python -c 'import secrets; print(secrets.token_hex())' SECRET_KEY = "abc123" # Replace me! diff --git a/pdm.lock b/pdm.lock index 6137c5a..90488fb 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2,10 +2,10 @@ # It is not intended for manual editing. [metadata] -groups = ["default", "auth-ldap", "auth-oauth", "auth-saml", "dev"] +groups = ["default", "auth-ldap", "auth-oauth", "auth-saml", "db-mysql", "db-postgres", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:724b4e719780cf213f4d1e15ff86e2f807d6c595b2e54595523c6fbd3615e247" +content_hash = "sha256:1af461aea0170421afe47c809cb315739413db60f16b0d60a7d38d91ddf457ca" [[metadata.targets]] requires_python = ">=3.12" @@ -950,6 +950,17 @@ files = [ {file = "multidict-6.1.0.tar.gz", hash = "sha256:22ae2ebf9b0c69d206c003e2f6a914ea33f0a932d4aa16f236afc049d9958f4a"}, ] +[[package]] +name = "mysqlclient" +version = "2.2.4" +requires_python = ">=3.8" +summary = "Python interface to MySQL" +groups = ["db-mysql"] +files = [ + {file = "mysqlclient-2.2.4-cp312-cp312-win_amd64.whl", hash = "sha256:e1ebe3f41d152d7cb7c265349fdb7f1eca86ccb0ca24a90036cde48e00ceb2ab"}, + {file = "mysqlclient-2.2.4.tar.gz", hash = "sha256:33bc9fb3464e7d7c10b1eaf7336c5ff8f2a3d3b88bab432116ad2490beb3bf41"}, +] + [[package]] name = "packaging" version = "24.1" @@ -1059,7 +1070,7 @@ name = "psycopg" version = "3.2.1" requires_python = ">=3.8" summary = "PostgreSQL database adapter for Python" -groups = ["default"] +groups = ["db-postgres"] dependencies = [ "backports-zoneinfo>=0.2.0; python_version < \"3.9\"", "typing-extensions>=4.4", @@ -1560,7 +1571,7 @@ name = "typing-extensions" version = "4.12.2" requires_python = ">=3.8" summary = "Backported and Experimental Type Hints for Python 3.8+" -groups = ["default"] +groups = ["default", "db-postgres"] files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, @@ -1571,7 +1582,7 @@ name = "tzdata" version = "2024.1" requires_python = ">=2" summary = "Provider of IANA time zone data" -groups = ["default"] +groups = ["db-postgres"] marker = "sys_platform == \"win32\"" files = [ {file = "tzdata-2024.1-py2.py3-none-any.whl", hash = "sha256:9068bc196136463f5245e51efda838afa15aaeca9903f49050dfa2679db4d252"}, diff --git a/pyproject.toml b/pyproject.toml index e680be9..2e3f528 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ dependencies = [ "flask-sqlalchemy~=3.1", "flask-wtf~=1.2", "uuid7~=0.1", - "psycopg~=3.2", "flask-weasyprint~=1.1", "python-webpack-boilerplate~=1.0", "pyipp @ git+https://github.com/ctalkington/python-ipp", @@ -33,6 +32,12 @@ auth-saml = [ auth-oauth = [ "Authlib~=1.3", ] +db-postgres = [ + "psycopg~=3.2", +] +db-mysql = [ + "mysqlclient~=2.2", +] [tool.pdm.dev-dependencies] dev = [ -- GitLab