SQLPyHelper 0.2.0__py3-none-any.whl → 0.2.1__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.
sqlpyhelper/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Match the version in setup.py
2
- __version__ = "0.2.0"
2
+ __version__ = "0.2.1"
3
3
 
4
4
  from sqlpyhelper.async_helper import ( # noqa: F401
5
5
  AsyncConnectionError,
@@ -28,7 +28,7 @@ Example usage::
28
28
 
29
29
  import logging
30
30
  import os
31
- from typing import Any, Optional
31
+ from typing import Any, List, Optional, Tuple
32
32
 
33
33
  from dotenv import load_dotenv
34
34
 
@@ -190,7 +190,7 @@ class AsyncSQLPyHelper:
190
190
  "No active connection. Call connect() or use async with."
191
191
  )
192
192
 
193
- def _adapt_query(self, query: str, args: tuple) -> tuple[str, tuple]:
193
+ def _adapt_query(self, query: str, args: tuple) -> Tuple[str, tuple]:
194
194
  """
195
195
  Adapt a query and its arguments for the active database driver.
196
196
 
@@ -320,7 +320,7 @@ class AsyncSQLPyHelper:
320
320
  except Exception as e:
321
321
  raise AsyncQueryError(f"fetch_one failed: {e}") from e
322
322
 
323
- async def fetch_all(self, query: str, *args: Any) -> list[Any]:
323
+ async def fetch_all(self, query: str, *args: Any) -> List[Any]:
324
324
  """
325
325
  Execute a SELECT query and return all rows.
326
326
 
@@ -409,7 +409,7 @@ class AsyncSQLPyHelper:
409
409
  except Exception as e:
410
410
  raise AsyncQueryError(f"fetch_val failed: {e}") from e
411
411
 
412
- async def execute_many(self, query: str, args_list: list[tuple]) -> None:
412
+ async def execute_many(self, query: str, args_list: List[tuple]) -> None:
413
413
  """
414
414
  Execute a SQL statement multiple times with different parameters.
415
415
  Efficient for bulk inserts::
sqlpyhelper/db_helper.py CHANGED
@@ -2,7 +2,7 @@ import csv
2
2
  import logging
3
3
  import os
4
4
  import re
5
- from typing import Any, Literal, Optional
5
+ from typing import Any, Dict, List, Literal, Optional
6
6
 
7
7
  from dotenv import load_dotenv
8
8
 
@@ -162,7 +162,7 @@ class SQLPyHelper:
162
162
  except Exception as e:
163
163
  raise QueryError(f"Failed to fetch row: {e}") from e
164
164
 
165
- def fetch_all(self) -> list[tuple]:
165
+ def fetch_all(self) -> List[tuple]:
166
166
  """Fetches all rows from the last executed query"""
167
167
  try:
168
168
  return self.cursor.fetchall()
@@ -171,7 +171,7 @@ class SQLPyHelper:
171
171
 
172
172
  def fetch_by_param(
173
173
  self, table_name: str, column_name: str, value: Any
174
- ) -> list[tuple]:
174
+ ) -> List[tuple]:
175
175
  """Fetches rows from a table where a column matches the given value."""
176
176
  try:
177
177
  table_name = _validate_identifier(table_name)
@@ -191,7 +191,7 @@ class SQLPyHelper:
191
191
  except Exception as e:
192
192
  raise ConnectionError(f"Failed to close connection: {e}") from e
193
193
 
194
- def create_table(self, table_name: str, columns: dict[str, str]) -> None:
194
+ def create_table(self, table_name: str, columns: Dict[str, str]) -> None:
195
195
  """
196
196
  Creates a table dynamically using a dictionary format.
197
197
  Example:
@@ -210,7 +210,7 @@ class SQLPyHelper:
210
210
  except Exception as e:
211
211
  raise QueryError(f"Failed to create table: {e}") from e
212
212
 
213
- def insert_bulk(self, table_name: str, data: list[dict[str, Any]]) -> None:
213
+ def insert_bulk(self, table_name: str, data: List[Dict[str, Any]]) -> None:
214
214
  """
215
215
  Inserts multiple rows at once.
216
216
  Example:
@@ -374,7 +374,7 @@ class SQLPyHelper:
374
374
  except Exception as e:
375
375
  raise QueryError(f"Failed to rollback transaction: {e}") from e
376
376
 
377
- def insert_dynamic(self, table: str, data: dict[str, Any]) -> None:
377
+ def insert_dynamic(self, table: str, data: Dict[str, Any]) -> None:
378
378
  """
379
379
  Dynamically constructs and executes an INSERT query with database-specific placeholders.
380
380
  """
sqlpyhelper/migration.py CHANGED
@@ -24,7 +24,7 @@ Example usage::
24
24
  """
25
25
 
26
26
  import logging
27
- from typing import Any, Optional
27
+ from typing import Any, Dict, List, Optional, Tuple
28
28
 
29
29
  logger = logging.getLogger("sqlpyhelper.migration")
30
30
 
@@ -41,7 +41,7 @@ class MigrationError(Exception):
41
41
  # Generic types are normalised from the source cursor description.
42
42
 
43
43
 
44
- _TYPE_MAP: dict[str, dict[str, str]] = {
44
+ _TYPE_MAP: Dict[str, Dict[str, str]] = {
45
45
  "sqlite": {
46
46
  "integer": "INTEGER",
47
47
  "real": "REAL",
@@ -149,7 +149,7 @@ def _map_type(raw_type: Optional[str], target_db: str) -> str:
149
149
  return target_types.get(generic, "TEXT")
150
150
 
151
151
 
152
- def _get_column_info(source: Any, table: str) -> list[tuple[str, str]]:
152
+ def _get_column_info(source: Any, table: str) -> List[Tuple[str, str]]:
153
153
  """
154
154
  Return a list of (column_name, raw_type_string) tuples
155
155
  by inspecting the source database schema.
@@ -216,7 +216,7 @@ def _get_column_info(source: Any, table: str) -> list[tuple[str, str]]:
216
216
 
217
217
  def _build_create_table_sql(
218
218
  table: str,
219
- columns: list[tuple[str, str]],
219
+ columns: List[Tuple[str, str]],
220
220
  target_db: str,
221
221
  ) -> str:
222
222
  """Build a CREATE TABLE IF NOT EXISTS statement for the target database."""
@@ -228,7 +228,7 @@ def _build_create_table_sql(
228
228
 
229
229
  def _build_insert_sql(
230
230
  table: str,
231
- column_names: list[str],
231
+ column_names: List[str],
232
232
  target_db: str,
233
233
  ) -> str:
234
234
  """Build a parameterised INSERT statement for the target database."""
@@ -250,7 +250,7 @@ def migrate_table(
250
250
  create_table: bool = True,
251
251
  batch_size: int = 500,
252
252
  truncate_target: bool = False,
253
- ) -> dict[str, Any]:
253
+ ) -> Dict[str, Any]:
254
254
  """
255
255
  Migrate a table from one database to another.
256
256
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SQLPyHelper
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A simple SQL database helper package for Python.
5
5
  Home-page: https://github.com/adebayopeter/sqlpyhelper
6
6
  Author: Adebayo Olaonipekun
@@ -0,0 +1,13 @@
1
+ sqlpyhelper/__init__.py,sha256=bQLc1BMk3n5DyZ_BlmBsZOzfCqdybgerRj85WKfV5Co,370
2
+ sqlpyhelper/async_helper.py,sha256=iHQKhyZtfi4Dfg7ZTjQRGYKg5NCMbtWCVHZCS-V9348,21486
3
+ sqlpyhelper/automation_utils.py,sha256=pC6pH6bJ-k8iPVeHJ4gUiwEe822dasmKg53ya9bMxyE,5381
4
+ sqlpyhelper/cli.py,sha256=yj0kWJu3oh_JLnmi0L7a5ing2_0x4CQGOKSOhZLAtoY,5646
5
+ sqlpyhelper/db_helper.py,sha256=vMNs8IIjNO6PdN9idcZGYWudF2AnnYm3OrE9YYzwc3Q,14421
6
+ sqlpyhelper/migration.py,sha256=vsEnBIvhNWn0srzlcTj_uxUt7ZMxjDpU_s1CM4txy4U,11692
7
+ sqlpyhelper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ sqlpyhelper-0.2.1.dist-info/licenses/LICENSE,sha256=9XzXxZ_8mWFM9-2TlqyE3L69zvRf4VPY_xIzSj5iU-g,1076
9
+ sqlpyhelper-0.2.1.dist-info/METADATA,sha256=7SD-1XaGrh4bjC7VLbhzgn9ZokdUsR_D6j0jwj24Ogk,11607
10
+ sqlpyhelper-0.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
11
+ sqlpyhelper-0.2.1.dist-info/entry_points.txt,sha256=uAzSqwkAbbJqQUKHlPNwOebTJVA0FqkOvn2CRP6xSz8,52
12
+ sqlpyhelper-0.2.1.dist-info/top_level.txt,sha256=FrLqTmqTGDa8jHnnf2ZVkYO-gFvLXX9QonpUCE6wKGs,12
13
+ sqlpyhelper-0.2.1.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- sqlpyhelper/__init__.py,sha256=zxVPeEAfG2pTAxvjU6D_U6x4ef4YMg4NqNFr-6SoSK0,370
2
- sqlpyhelper/async_helper.py,sha256=beq0wKxDl7Qv-CW_qA1-h_DPhDpC1CQHdstnKO-4FSI,21473
3
- sqlpyhelper/automation_utils.py,sha256=pC6pH6bJ-k8iPVeHJ4gUiwEe822dasmKg53ya9bMxyE,5381
4
- sqlpyhelper/cli.py,sha256=yj0kWJu3oh_JLnmi0L7a5ing2_0x4CQGOKSOhZLAtoY,5646
5
- sqlpyhelper/db_helper.py,sha256=zRZGidneQspAhYekD7ACvn9nim3ylYav_ObbCLxRXaM,14409
6
- sqlpyhelper/migration.py,sha256=byAn7ToVgIB8tl1N39DB0MbHigjH2l-qX7QSskgzzTg,11673
7
- sqlpyhelper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- sqlpyhelper-0.2.0.dist-info/licenses/LICENSE,sha256=9XzXxZ_8mWFM9-2TlqyE3L69zvRf4VPY_xIzSj5iU-g,1076
9
- sqlpyhelper-0.2.0.dist-info/METADATA,sha256=mI3df5g2wPddtecAYNcq95ipzwoXyHA15b2UhAuj300,11607
10
- sqlpyhelper-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
11
- sqlpyhelper-0.2.0.dist-info/entry_points.txt,sha256=uAzSqwkAbbJqQUKHlPNwOebTJVA0FqkOvn2CRP6xSz8,52
12
- sqlpyhelper-0.2.0.dist-info/top_level.txt,sha256=FrLqTmqTGDa8jHnnf2ZVkYO-gFvLXX9QonpUCE6wKGs,12
13
- sqlpyhelper-0.2.0.dist-info/RECORD,,