Skip to content

Commit 55a44e7

Browse files
committed
Started making PSQLPy SQLAlchemy compatible
1 parent 519c4d4 commit 55a44e7

20 files changed

+984
-855
lines changed

python/psqlpy/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
ReadVariant,
1414
SingleQueryResult,
1515
SslMode,
16-
SynchronousCommit,
1716
TargetSessionAttrs,
1817
Transaction,
1918
connect,
@@ -35,7 +34,6 @@
3534
"ReadVariant",
3635
"SingleQueryResult",
3736
"SslMode",
38-
"SynchronousCommit",
3937
"TargetSessionAttrs",
4038
"Transaction",
4139
"connect",

python/psqlpy/_internal/__init__.pyi

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -150,38 +150,6 @@ class SingleQueryResult:
150150
Type that return passed function.
151151
"""
152152

153-
class SynchronousCommit(Enum):
154-
"""
155-
Synchronous_commit option for transactions.
156-
157-
### Variants:
158-
- `On`: The meaning may change based on whether you have
159-
a synchronous standby or not.
160-
If there is a synchronous standby,
161-
setting the value to on will result in waiting till “remote flush”.
162-
- `Off`: As the name indicates, the commit acknowledgment can come before
163-
flushing the records to disk.
164-
This is generally called as an asynchronous commit.
165-
If the PostgreSQL instance crashes,
166-
the last few asynchronous commits might be lost.
167-
- `Local`: WAL records are written and flushed to local disks.
168-
In this case, the commit will be acknowledged after the
169-
local WAL Write and WAL flush completes.
170-
- `RemoteWrite`: WAL records are successfully handed over to
171-
remote instances which acknowledged back
172-
about the write (not flush).
173-
- `RemoteApply`: This will result in commits waiting until replies from the
174-
current synchronous standby(s) indicate they have received
175-
the commit record of the transaction and applied it so
176-
that it has become visible to queries on the standby(s).
177-
"""
178-
179-
On = 1
180-
Off = 2
181-
Local = 3
182-
RemoteWrite = 4
183-
RemoteApply = 5
184-
185153
class IsolationLevel(Enum):
186154
"""Isolation Level for transactions."""
187155

@@ -1117,15 +1085,13 @@ class Connection:
11171085
isolation_level: IsolationLevel | None = None,
11181086
read_variant: ReadVariant | None = None,
11191087
deferrable: bool | None = None,
1120-
synchronous_commit: SynchronousCommit | None = None,
11211088
) -> Transaction:
11221089
"""Create new transaction.
11231090
11241091
### Parameters:
11251092
- `isolation_level`: configure isolation level of the transaction.
11261093
- `read_variant`: configure read variant of the transaction.
11271094
- `deferrable`: configure deferrable of the transaction.
1128-
- `synchronous_commit`: configure synchronous_commit option for transaction.
11291095
"""
11301096
def cursor(
11311097
self: Self,

python/tests/test_transaction.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
Cursor,
99
IsolationLevel,
1010
ReadVariant,
11-
SynchronousCommit,
1211
)
1312
from psqlpy.exceptions import (
1413
InterfaceError,
@@ -362,29 +361,3 @@ async def test_execute_batch_method(psql_pool: ConnectionPool) -> None:
362361
await transaction.execute(querystring="SELECT * FROM execute_batch2")
363362

364363
connection.back_to_pool()
365-
366-
367-
@pytest.mark.parametrize(
368-
"synchronous_commit",
369-
[
370-
SynchronousCommit.On,
371-
SynchronousCommit.Off,
372-
SynchronousCommit.Local,
373-
SynchronousCommit.RemoteWrite,
374-
SynchronousCommit.RemoteApply,
375-
],
376-
)
377-
async def test_synchronous_commit(
378-
synchronous_commit: SynchronousCommit,
379-
psql_pool: ConnectionPool,
380-
table_name: str,
381-
number_database_records: int,
382-
) -> None:
383-
async with psql_pool.acquire() as conn, conn.transaction(
384-
synchronous_commit=synchronous_commit,
385-
) as trans:
386-
res = await trans.execute(
387-
f"SELECT * FROM {table_name}",
388-
)
389-
390-
assert len(res.result()) == number_database_records

0 commit comments

Comments
 (0)