tracktolib 0.57.0__py3-none-any.whl → 0.58.0__py3-none-any.whl

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/pg_sync.py CHANGED
@@ -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')
@@ -103,22 +103,32 @@ def insert_one(
103
103
  ) -> dict: ...
104
104
 
105
105
 
106
+ @overload
106
107
  def insert_one(
107
- engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString] | None = None
108
- ) -> dict | None:
108
+ engine: Cursor, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString]
109
+ ) -> DictRow | TupleRow | None: ...
110
+
111
+
112
+ def insert_one(
113
+ engine: Connection | Cursor,
114
+ table: LiteralString,
115
+ data: Mapping[str, Any],
116
+ returning: list[LiteralString] | None = None,
117
+ ) -> dict | DictRow | TupleRow | None:
109
118
  query, _data = get_insert_data(table, [data])
110
119
  _is_returning = False
111
120
  if returning:
112
121
  query = f"{query} RETURNING {','.join(returning)}"
113
122
  _is_returning = True
114
123
 
115
- with engine.cursor(row_factory=dict_row) as cur:
116
- _ = cur.execute(query, _data[0])
117
- if _is_returning:
118
- resp = cur.fetchone()
119
- else:
120
- resp = None
121
- engine.commit()
124
+ if isinstance(engine, Connection):
125
+ with engine.cursor(row_factory=dict_row) as cur:
126
+ _ = cur.execute(query, _data[0])
127
+ resp = cur.fetchone() if _is_returning else None
128
+ engine.commit()
129
+ else:
130
+ _ = engine.execute(query, _data[0])
131
+ resp = engine.fetchone() if _is_returning else None
122
132
  return resp
123
133
 
124
134
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tracktolib
3
- Version: 0.57.0
3
+ Version: 0.58.0
4
4
  Summary: Utility library for python
5
5
  License: MIT
6
6
  Keywords: utility
@@ -5,14 +5,14 @@ tracktolib/logs.py,sha256=xgfRDnviZPr9qinSOgab8neIWPv9Rj2xzDHnIBvWQcU,2201
5
5
  tracktolib/pg/__init__.py,sha256=j67e3B3gBbCHLD20QBybptmNdbbVMzNhZE6XjIPuKVo,349
6
6
  tracktolib/pg/query.py,sha256=MBYOTL9aLnYRBhaLy8-P6uGNXOmyluejNyUdt3Gfx5M,14504
7
7
  tracktolib/pg/utils.py,sha256=cL24KEt4SWJQ7LJPzaO3c8Xg0ZLmjhn22DtTWg86nwc,6324
8
- tracktolib/pg_sync.py,sha256=snfYtj5ICWa2C_QWRFKZecHPgVx1yhofhGst0e6CGxs,6351
8
+ tracktolib/pg_sync.py,sha256=GvrJfEkML2p7L4DY7EAsL2qft-3l87jngpgYwC3iz18,6703
9
9
  tracktolib/pg_utils.py,sha256=VXPpy1jGq6aCgTlfFJDIrq6JDujR83JN5ZRiCi8Lx4E,2582
10
10
  tracktolib/s3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  tracktolib/s3/minio.py,sha256=wMEjkSes9Fp39fD17IctALpD6zB2xwDRQEmO7Vzan3g,1387
12
12
  tracktolib/s3/s3.py,sha256=0HbSAPoaup5-W4LK54zRCjrQ5mr8OWR-N9WjW99Q4aw,5937
13
13
  tracktolib/tests.py,sha256=gKE--epQjgMZGXc5ydbl4zjOdmwztJS42UMV0p4hXEA,399
14
14
  tracktolib/utils.py,sha256=ysTBF9V35fVXQVBPk0kfE_84SGRxzrayqmg9RbtoJq4,5761
15
- tracktolib-0.57.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
16
- tracktolib-0.57.0.dist-info/METADATA,sha256=88PzWoI3eX1blMUAWEHUzuYFPWndH7O0sCPr9_ScSNE,3704
17
- tracktolib-0.57.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
- tracktolib-0.57.0.dist-info/RECORD,,
15
+ tracktolib-0.58.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
16
+ tracktolib-0.58.0.dist-info/METADATA,sha256=GHO46HMt3K1DMn4jMoOjIUaUlnPCjpUBTciyu9qljs0,3704
17
+ tracktolib-0.58.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
+ tracktolib-0.58.0.dist-info/RECORD,,