fastasyncpg 0.0.8__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastasyncpg-0.0.8/fastasyncpg.egg-info → fastasyncpg-0.0.9}/PKG-INFO +1 -1
- fastasyncpg-0.0.9/fastasyncpg/__init__.py +1 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg/_modidx.py +5 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg/core.py +24 -3
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9/fastasyncpg.egg-info}/PKG-INFO +1 -1
- fastasyncpg-0.0.8/fastasyncpg/__init__.py +0 -1
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/LICENSE +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/MANIFEST.in +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/README.md +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/SOURCES.txt +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/dependency_links.txt +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/entry_points.txt +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/requires.txt +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/top_level.txt +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/pyproject.toml +0 -0
- {fastasyncpg-0.0.8 → fastasyncpg-0.0.9}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.9"
|
|
@@ -97,7 +97,12 @@ d = { 'settings': { 'branch': 'main',
|
|
|
97
97
|
'fastasyncpg.core._prep_row': ('core.html#_prep_row', 'fastasyncpg/core.py'),
|
|
98
98
|
'fastasyncpg.core._process_row': ('core.html#_process_row', 'fastasyncpg/core.py'),
|
|
99
99
|
'fastasyncpg.core._select_sql': ('core.html#_select_sql', 'fastasyncpg/core.py'),
|
|
100
|
+
'fastasyncpg.core._sql_kinds': ('core.html#_sql_kinds', 'fastasyncpg/core.py'),
|
|
100
101
|
'fastasyncpg.core.all_dcs': ('core.html#all_dcs', 'fastasyncpg/core.py'),
|
|
102
|
+
'fastasyncpg.core.asyncpg.Connection._do_execute': ( 'core.html#asyncpg.connection._do_execute',
|
|
103
|
+
'fastasyncpg/core.py'),
|
|
104
|
+
'fastasyncpg.core.asyncpg.Connection.execute': ( 'core.html#asyncpg.connection.execute',
|
|
105
|
+
'fastasyncpg/core.py'),
|
|
101
106
|
'fastasyncpg.core.col_def': ('core.html#col_def', 'fastasyncpg/core.py'),
|
|
102
107
|
'fastasyncpg.core.columns_info': ('core.html#columns_info', 'fastasyncpg/core.py'),
|
|
103
108
|
'fastasyncpg.core.connect': ('core.html#connect', 'fastasyncpg/core.py'),
|
|
@@ -10,7 +10,7 @@ __all__ = ['pg_to_py', 'py_to_pg', 'Results', 'FRecord', 'table_names', 'view_na
|
|
|
10
10
|
# %% ../nbs/00_core.ipynb #222d751e
|
|
11
11
|
from fastcore.utils import *
|
|
12
12
|
from contextlib import asynccontextmanager
|
|
13
|
-
import asyncpg,traceback
|
|
13
|
+
import asyncpg,traceback,sys
|
|
14
14
|
from asyncpg import connection,protocol
|
|
15
15
|
|
|
16
16
|
# %% ../nbs/00_core.ipynb #cdb9cd9e
|
|
@@ -463,7 +463,7 @@ def _process_row(row, kwargs):
|
|
|
463
463
|
# %% ../nbs/00_core.ipynb #343a8cc8
|
|
464
464
|
def _prep_row(record, kwargs):
|
|
465
465
|
row = _process_row(record, kwargs)
|
|
466
|
-
if not row: return None*3
|
|
466
|
+
if not row: return [None]*3
|
|
467
467
|
cols = ', '.join(f'"{k}"' for k in row)
|
|
468
468
|
vals = ', '.join(f'${i+1}' for i in range(len(row)))
|
|
469
469
|
return row, cols, vals
|
|
@@ -693,6 +693,27 @@ async def transaction(self:Database):
|
|
|
693
693
|
async with self.acquire() as db:
|
|
694
694
|
async with db.conn.transaction(): yield db
|
|
695
695
|
|
|
696
|
+
# %% ../nbs/00_core.ipynb #0f3e2764
|
|
697
|
+
def _sql_kinds(sql):
|
|
698
|
+
"Yield (cat, kind) for each non-SELECT DML/DDL statement in `sql`"
|
|
699
|
+
for s in sqlparse.parse(sql):
|
|
700
|
+
for t in s.flatten():
|
|
701
|
+
if t.ttype is tokens.Keyword.DML:
|
|
702
|
+
if t.value.upper() != 'SELECT': yield ('dml', t.value.upper())
|
|
703
|
+
elif t.ttype is tokens.Keyword.DDL: yield ('ddl', t.value.upper())
|
|
704
|
+
|
|
705
|
+
@patch
|
|
706
|
+
async def _do_execute(self:asyncpg.Connection, query, executor, timeout, retry=True, *, ignore_custom_codec=False, record_class=None):
|
|
707
|
+
for cat, kind in _sql_kinds(query): sys.audit(f'fastaudit.{cat}', kind, query)
|
|
708
|
+
return await self._orig__do_execute(query, executor, timeout, retry, ignore_custom_codec=ignore_custom_codec, record_class=record_class)
|
|
709
|
+
|
|
710
|
+
@patch
|
|
711
|
+
async def execute(self:asyncpg.Connection, query, *args, timeout=None):
|
|
712
|
+
"Execute an SQL command (or commands)."
|
|
713
|
+
if not args:
|
|
714
|
+
for cat, kind in _sql_kinds(query): sys.audit(f'fastaudit.{cat}', kind, query)
|
|
715
|
+
return await self._orig_execute(query, *args, timeout=timeout)
|
|
716
|
+
|
|
696
717
|
# %% ../nbs/00_core.ipynb #de4c0d24
|
|
697
718
|
@patch
|
|
698
719
|
async def claim(self:Table, where=None, where_args=None, order_by=None, limit=1):
|
|
@@ -715,9 +736,9 @@ async def claim_one(self:Table, status_col='status', pending='pending', complete
|
|
|
715
736
|
tbl = txn.t[self.name]
|
|
716
737
|
p.db = txn
|
|
717
738
|
p.evt = await tbl.claim(where=f'"{status_col}"=$1', where_args=[pending], order_by=order_by)
|
|
718
|
-
if p.evt is None: return
|
|
719
739
|
try: yield p
|
|
720
740
|
except Exception as e: p.failed, p.exc, p.tb = True, e, traceback.format_exc()
|
|
741
|
+
if p.evt is None: return
|
|
721
742
|
pk = self.pks[0]
|
|
722
743
|
new = failed if p.failed else (None if p.retry else completed)
|
|
723
744
|
stmt = f'UPDATE {self} SET "{status_col}"=$1 WHERE "{pk}"=$2'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.8"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|