Skip to content

Commit

Permalink
Upgrade to SQLAlchemy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smsearcy committed May 6, 2024
1 parent 5f9c1e1 commit 4f7de09
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ MESH_INFO_LOG_LEVEL="INFO"
MESH_INFO_MAP_TILE_URL=""
MESH_INFO_MAP_TILE_ATTRIBUTION=""
#MESH_INFO_DATA_DIR="/var/lib/mesh-info"
#MESH_INFO_DB_URL="postgresql+psycopg2://postgres:postgres@localhost:5432/postgres"
#MESH_INFO_DB_URL="postgresql+psycopg://postgres:postgres@localhost:5432/postgres"
2 changes: 1 addition & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Example
MESH_INFO_LOG_LEVEL=INFO
MESH_INFO_MAP_TILE_URL="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png"
MESH_INFO_MAP_TILE_ATTRIBUTION='&copy; <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a> <a href="https://stamen.com/" target="_blank">&copy; Stamen Design</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'
MESH_INFO_DB_URL="postgresql+psycopg2://postgres:password@localhost:5432/postgres"
MESH_INFO_DB_URL="postgresql+psycopg://postgres:password@localhost:5432/postgres"
Options
Expand Down
4 changes: 2 additions & 2 deletions meshinfo/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@


def get_engine(settings):
return create_engine(future=True, **attr.asdict(settings))
return create_engine(**attr.asdict(settings))


def get_session_factory(engine) -> sessionmaker:
factory = sessionmaker(engine, future=True)
factory = sessionmaker(engine)
return factory


Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"gunicorn ~= 22.0",
"pendulum ~= 2.1",
"platformdirs ~= 2.0",
"psycopg2 ~= 2.9",
"psycopg ~= 3.0",
"pyramid ~= 2.0",
"pyramid-jinja2 ~= 2.10",
"pyramid-retry ~= 2.1",
Expand All @@ -35,7 +35,7 @@ dependencies = [
"rich ~= 13.3",
"rrdtool",
"structlog ~= 23.2",
"sqlalchemy ~= 1.4",
"sqlalchemy ~= 2.0",
"transaction ~= 3.0",
"zope.sqlalchemy ~= 3.0",
]
Expand All @@ -55,11 +55,11 @@ tests = [
"WebTest",
"flake8-bugbear",
"flake8",
"mypy ~= 1.5.1",
"mypy ~= 1.10",
"pytest-asyncio",
"pytest-cov",
"pytest-mock",
"pytest-postgresql < 4.0",
"pytest-postgresql",
"pytest",
]
dev = [
Expand Down
15 changes: 10 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements.txt --resolver=backtracking pyproject.toml
# pip-compile --output-file=requirements.txt pyproject.toml
#
aiohttp==3.8.6
# via mesh-info (pyproject.toml)
Expand Down Expand Up @@ -51,7 +51,9 @@ multidict==6.0.4
# aiohttp
# yarl
packaging==23.2
# via gunicorn
# via
# gunicorn
# zope-sqlalchemy
pastedeploy==3.0.1
# via plaster-pastedeploy
pendulum==2.1.2
Expand All @@ -64,7 +66,7 @@ plaster-pastedeploy==1.0.1
# via pyramid
platformdirs==2.6.2
# via mesh-info (pyproject.toml)
psycopg2==2.9.9
psycopg==3.1.18
# via mesh-info (pyproject.toml)
pygments==2.16.1
# via rich
Expand Down Expand Up @@ -95,7 +97,7 @@ rrdtool==0.1.16
# via mesh-info (pyproject.toml)
six==1.16.0
# via python-dateutil
sqlalchemy==1.4.50
sqlalchemy==2.0.30
# via
# alembic
# mesh-info (pyproject.toml)
Expand All @@ -110,7 +112,10 @@ transaction==3.1.0
translationstring==1.4
# via pyramid
typing-extensions==4.8.0
# via alembic
# via
# alembic
# psycopg
# sqlalchemy
venusian==3.0.0
# via pyramid
webob==1.8.7
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def dbengine(request, tmp_path):
host = dbinfo.host
port = dbinfo.port
dbname = dbinfo.dbname
db_url = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{dbname}"
db_url = f"postgresql+psycopg://{user}:{password}@{host}:{port}/{dbname}"
else:
raise ValueError(f"Unknown param: {request.param!r}")

Expand Down

0 comments on commit 4f7de09

Please sign in to comment.