fastasyncpg 0.0.7__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.7/fastasyncpg.egg-info → fastasyncpg-0.0.9}/PKG-INFO +1 -1
- fastasyncpg-0.0.9/fastasyncpg/__init__.py +1 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg/_modidx.py +5 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg/core.py +25 -2
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9/fastasyncpg.egg-info}/PKG-INFO +1 -1
- fastasyncpg-0.0.7/fastasyncpg/__init__.py +0 -1
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/LICENSE +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/MANIFEST.in +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/README.md +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/SOURCES.txt +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/dependency_links.txt +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/entry_points.txt +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/requires.txt +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/fastasyncpg.egg-info/top_level.txt +0 -0
- {fastasyncpg-0.0.7 → fastasyncpg-0.0.9}/pyproject.toml +0 -0
- {fastasyncpg-0.0.7 → 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'),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Docs: https://AnswerDotAI.github.io/fastasyncpgcore.html.md"""
|
|
2
|
+
|
|
1
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
2
4
|
|
|
3
5
|
# %% auto #0
|
|
@@ -8,7 +10,7 @@ __all__ = ['pg_to_py', 'py_to_pg', 'Results', 'FRecord', 'table_names', 'view_na
|
|
|
8
10
|
# %% ../nbs/00_core.ipynb #222d751e
|
|
9
11
|
from fastcore.utils import *
|
|
10
12
|
from contextlib import asynccontextmanager
|
|
11
|
-
import asyncpg,traceback
|
|
13
|
+
import asyncpg,traceback,sys
|
|
12
14
|
from asyncpg import connection,protocol
|
|
13
15
|
|
|
14
16
|
# %% ../nbs/00_core.ipynb #cdb9cd9e
|
|
@@ -461,7 +463,7 @@ def _process_row(row, kwargs):
|
|
|
461
463
|
# %% ../nbs/00_core.ipynb #343a8cc8
|
|
462
464
|
def _prep_row(record, kwargs):
|
|
463
465
|
row = _process_row(record, kwargs)
|
|
464
|
-
if not row: return None*3
|
|
466
|
+
if not row: return [None]*3
|
|
465
467
|
cols = ', '.join(f'"{k}"' for k in row)
|
|
466
468
|
vals = ', '.join(f'${i+1}' for i in range(len(row)))
|
|
467
469
|
return row, cols, vals
|
|
@@ -691,6 +693,27 @@ async def transaction(self:Database):
|
|
|
691
693
|
async with self.acquire() as db:
|
|
692
694
|
async with db.conn.transaction(): yield db
|
|
693
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
|
+
|
|
694
717
|
# %% ../nbs/00_core.ipynb #de4c0d24
|
|
695
718
|
@patch
|
|
696
719
|
async def claim(self:Table, where=None, where_args=None, order_by=None, limit=1):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.7"
|
|
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
|