tracktolib 0.55.0__tar.gz → 0.56.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tracktolib
3
- Version: 0.55.0
3
+ Version: 0.56.0
4
4
  Summary: Utility library for python
5
5
  License: MIT
6
6
  Keywords: utility
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tracktolib"
3
- version = "0.55.0"
3
+ version = "0.56.0"
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.55.0"
86
+ version = "0.56.0"
87
87
  tag_format = "$version"
88
88
  version_files = [
89
89
  "pyproject.toml:version"
@@ -14,7 +14,6 @@ except ImportError:
14
14
 
15
15
  from .pg_utils import get_tmp_table_query
16
16
 
17
-
18
17
  __all__ = (
19
18
  "clean_tables",
20
19
  "drop_db",
@@ -81,11 +80,15 @@ def get_insert_data(table: LiteralString, data: list[dict]) -> tuple[LiteralStri
81
80
  return query, [tuple(_parse_value(_x) for _x in x.values()) for x in data]
82
81
 
83
82
 
84
- def insert_many(engine: Connection, table: LiteralString, data: list[dict]):
83
+ def insert_many(engine: Connection | Cursor, table: LiteralString, data: list[dict]):
85
84
  query, _data = get_insert_data(table, data)
86
- with engine.cursor() as cur:
87
- _ = cur.executemany(query, _data)
88
- engine.commit()
85
+ if isinstance(engine, Connection):
86
+ with engine.cursor() as cur:
87
+ _ = cur.executemany(query, _data)
88
+ engine.commit()
89
+ else:
90
+ # If we are using a cursor, we can use executemany directly
91
+ _ = engine.executemany(query, _data)
89
92
 
90
93
 
91
94
  @overload
@@ -138,11 +141,11 @@ def clean_tables(engine: Connection, tables: Iterable[LiteralString], reset_seq:
138
141
 
139
142
  def get_tables(engine: Connection, schemas: list[str], ignored_tables: Iterable[str] | None = None):
140
143
  table_query = """
141
- SELECT CONCAT_WS('.', schemaname, tablename) AS table
142
- FROM pg_catalog.pg_tables
143
- WHERE schemaname = ANY(%s)
144
- ORDER BY schemaname, tablename
145
- """
144
+ SELECT CONCAT_WS('.', schemaname, tablename) AS table
145
+ FROM pg_catalog.pg_tables
146
+ WHERE schemaname = ANY (%s)
147
+ ORDER BY schemaname, tablename \
148
+ """
146
149
  resp = fetch_all(engine, table_query, schemas)
147
150
 
148
151
  # Foreign keys
File without changes
File without changes