tracktolib 0.57.0__tar.gz → 0.58.1__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.
- {tracktolib-0.57.0 → tracktolib-0.58.1}/PKG-INFO +1 -1
- {tracktolib-0.57.0 → tracktolib-0.58.1}/pyproject.toml +2 -2
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/pg_sync.py +23 -11
- {tracktolib-0.57.0 → tracktolib-0.58.1}/LICENSE +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/README.md +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/__init__.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/api.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/http_utils.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/logs.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/pg/__init__.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/pg/query.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/pg/utils.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/pg_utils.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/s3/__init__.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/s3/minio.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/s3/s3.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/tests.py +0 -0
- {tracktolib-0.57.0 → tracktolib-0.58.1}/tracktolib/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tracktolib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.58.1"
|
|
4
4
|
description = "Utility library for python"
|
|
5
5
|
authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -83,7 +83,7 @@ pythonPlatform = "Linux"
|
|
|
83
83
|
|
|
84
84
|
[tool.commitizen]
|
|
85
85
|
name = "cz_conventional_commits"
|
|
86
|
-
version = "0.
|
|
86
|
+
version = "0.58.1"
|
|
87
87
|
tag_format = "$version"
|
|
88
88
|
version_files = [
|
|
89
89
|
"pyproject.toml:version"
|
|
@@ -7,7 +7,7 @@ try:
|
|
|
7
7
|
from psycopg import Connection, Cursor
|
|
8
8
|
from psycopg.abc import Query
|
|
9
9
|
from psycopg.errors import InvalidCatalogName
|
|
10
|
-
from psycopg.rows import dict_row
|
|
10
|
+
from psycopg.rows import dict_row, DictRow, TupleRow
|
|
11
11
|
from psycopg.types.json import Json
|
|
12
12
|
except ImportError:
|
|
13
13
|
raise ImportError('Please install psycopg or tracktolib with "pg-sync" to use this module')
|
|
@@ -94,7 +94,9 @@ def insert_many(engine: Connection | Cursor, table: LiteralString, data: Sequenc
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
@overload
|
|
97
|
-
def insert_one(
|
|
97
|
+
def insert_one(
|
|
98
|
+
engine: Connection | Cursor, table: LiteralString, data: Mapping[str, Any], returning: None = None
|
|
99
|
+
) -> None: ...
|
|
98
100
|
|
|
99
101
|
|
|
100
102
|
@overload
|
|
@@ -103,22 +105,32 @@ def insert_one(
|
|
|
103
105
|
) -> dict: ...
|
|
104
106
|
|
|
105
107
|
|
|
108
|
+
@overload
|
|
109
|
+
def insert_one(
|
|
110
|
+
engine: Cursor, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString]
|
|
111
|
+
) -> DictRow | TupleRow | None: ...
|
|
112
|
+
|
|
113
|
+
|
|
106
114
|
def insert_one(
|
|
107
|
-
engine: Connection
|
|
108
|
-
|
|
115
|
+
engine: Connection | Cursor,
|
|
116
|
+
table: LiteralString,
|
|
117
|
+
data: Mapping[str, Any],
|
|
118
|
+
returning: list[LiteralString] | None = None,
|
|
119
|
+
) -> dict | DictRow | TupleRow | None:
|
|
109
120
|
query, _data = get_insert_data(table, [data])
|
|
110
121
|
_is_returning = False
|
|
111
122
|
if returning:
|
|
112
123
|
query = f"{query} RETURNING {','.join(returning)}"
|
|
113
124
|
_is_returning = True
|
|
114
125
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
resp = cur.fetchone()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
if isinstance(engine, Connection):
|
|
127
|
+
with engine.cursor(row_factory=dict_row) as cur:
|
|
128
|
+
_ = cur.execute(query, _data[0])
|
|
129
|
+
resp = cur.fetchone() if _is_returning else None
|
|
130
|
+
engine.commit()
|
|
131
|
+
else:
|
|
132
|
+
_ = engine.execute(query, _data[0])
|
|
133
|
+
resp = engine.fetchone() if _is_returning else None
|
|
122
134
|
return resp
|
|
123
135
|
|
|
124
136
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|