Skip to content

Commit

Permalink
initial sqlalchemy-2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
matjam committed Jan 11, 2024
1 parent ae1653b commit c96a3bb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.18
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ default: install lint tests

venv:
# Create a local virtual environment in `venv/`
ifdef CI
# Don't pin Python version in CI; instead, defer to Travis
virtualenv --no-site-packages $(VENV_DIR)
else
# Use Python 3.7 for local development
virtualenv --no-site-packages --python=python3.7 $(VENV_DIR)
endif
python -mvenv $(VENV_DIR)

install: venv
# Install Python dev dependencies into local venv
Expand Down Expand Up @@ -51,7 +45,7 @@ endif

tests:
# Run pytest with coverage
@$(VENV_RUN)pytest --cov=. tests
@SQLALCHEMY_WARN_20=1 $(VENV_RUN)pytest --cov=. tests

.PHONY: lint tests

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: '3'
version: "3"

volumes:
pg_data:

services:
postgres:
image: postgres:9.6.3
image: postgres:latest
ports:
- 5543:5432
volumes:
- pg_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
psycopg2==2.8.3
six==1.12.0
sqlalchemy==1.3.7
psycopg2==2.9.9
six==1.16.0
sqlalchemy==1.4.51
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from setuptools import find_packages, setup

install_requires = ["psycopg2>=2.7", "six>=1.12.0", "SQLAlchemy>=1.0"]
install_requires = ["psycopg2>=2.7", "six>=1.12.0", "SQLAlchemy>=1.4"]
test_requires = ["pytest", "pytest-cov", "pytest-mock"]
dev_requires = test_requires + [
"autopep8>=1.4.4",
'black>=18.0.b0,<19;python_version>="3.6"',
"black>=23",
"flake8",
"ipython",
"isort>=4.3.21",
Expand All @@ -30,6 +30,8 @@
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: SQL
Topic :: Database
Topic :: Database :: Front-Ends
Expand Down
2 changes: 1 addition & 1 deletion src/savage/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
text,
)
from sqlalchemy.dialects import postgresql
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import declared_attr
from sqlalchemy.orm.attributes import InstrumentedAttribute

from savage import utils
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import

import pytest
from sqlalchemy import create_engine
from sqlalchemy import create_engine, text

import savage
from savage.utils import savage_json_serializer
Expand Down Expand Up @@ -41,7 +41,7 @@ def session(engine):
# Clean up
_session.close()
for tablename in Base.metadata.tables.keys():
connection.execute("DELETE FROM {}".format(tablename))
connection.execute(text("DELETE FROM {}".format(tablename)))
connection.close()


Expand Down
2 changes: 1 addition & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
UniqueConstraint,
)
from sqlalchemy.dialects import postgresql
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base

from savage.models import SavageLogMixin, SavageModelMixin

Expand Down

0 comments on commit c96a3bb

Please sign in to comment.