Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ UPGRADE: psycopg2 allow v2.9 #5104

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ dependencies:
- pamqp~=2.3
- paramiko>=2.7.2,~=2.7
- plumpy~=0.20.0
- pgsu~=0.2.0
- pgsu~=0.2.1
- psutil~=5.6
- psycopg2-binary~=2.8.3
- psycopg2-binary~=2.8
- python-dateutil~=2.8
- pytz~=2021.1
- pyyaml~=5.4
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ dependencies = [
"pamqp~=2.3",
"paramiko~=2.7,>=2.7.2",
"plumpy~=0.20.0",
"pgsu~=0.2.0",
"pgsu~=0.2.1",
"psutil~=5.6",
"psycopg2-binary~=2.8.3",
"psycopg2-binary~=2.8",
"python-dateutil~=2.8",
"pytz~=2021.1",
"pyyaml~=5.4",
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ plumpy==0.20.0
prometheus-client==0.12.0
prompt-toolkit==3.0.23
psutil==5.8.0
psycopg2-binary==2.8.6
psycopg2-binary==2.9.1
ptyprocess==0.7.0
py==1.11.0
py-cpuinfo==8.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ plumpy==0.20.0
prometheus-client==0.12.0
prompt-toolkit==3.0.23
psutil==5.8.0
psycopg2-binary==2.8.6
psycopg2-binary==2.9.1
ptyprocess==0.7.0
py==1.11.0
py-cpuinfo==8.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ plumpy==0.20.0
prometheus-client==0.12.0
prompt-toolkit==3.0.23
psutil==5.8.0
psycopg2-binary==2.8.6
psycopg2-binary==2.9.1
ptyprocess==0.7.0
py==1.11.0
py-cpuinfo==8.0.0
Expand Down
14 changes: 12 additions & 2 deletions tests/backends/aiida_sqlalchemy/migrations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ def uninitialised_profile(empty_pg_cluster: PGTest, tmp_path): # pylint: disabl

database_name = f'test_{uuid4().hex}'

with psycopg2.connect(**empty_pg_cluster.dsn) as conn:
conn = None
try:
conn = psycopg2.connect(**empty_pg_cluster.dsn)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
with conn.cursor() as cursor:
cursor.execute(f"CREATE DATABASE {database_name} ENCODING 'utf8';")
finally:
if conn:
conn.close()

yield Profile(
'test_migrate', {
Expand All @@ -61,14 +66,19 @@ def uninitialised_profile(empty_pg_cluster: PGTest, tmp_path): # pylint: disabl
}
)

with psycopg2.connect(**empty_pg_cluster.dsn) as conn:
conn = None
try:
conn = psycopg2.connect(**empty_pg_cluster.dsn)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
with conn.cursor() as cursor:
# note after postgresql 13 you can use 'DROP DATABASE name WITH (FORCE)'
# but for now, we first close all possible open connections to the database, before dropping it
# see: https://dba.stackexchange.com/questions/11893/force-drop-db-while-others-may-be-connected
cursor.execute(f"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '{database_name}';")
cursor.execute(f'DROP DATABASE {database_name};')
finally:
if conn:
conn.close()


@pytest.fixture()
Expand Down