esuls 0.1.16__tar.gz → 0.1.17__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.4
2
2
  Name: esuls
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Utility library for async database operations, HTTP requests, and parallel execution
5
5
  Author-email: IperGiove <ipergiove@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "esuls"
7
- version = "0.1.16"
7
+ version = "0.1.17"
8
8
  description = "Utility library for async database operations, HTTP requests, and parallel execution"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"
@@ -334,9 +334,11 @@ class AsyncDB(Generic[SchemaType]):
334
334
  columns = ','.join(field_names)
335
335
  placeholders = ','.join('?' for _ in field_names)
336
336
 
337
+ set_clause = ','.join(f'{col}=excluded.{col}' for col in field_names if col != 'created_at')
337
338
  return f"""
338
- INSERT OR REPLACE INTO {self.table_name} ({columns},id)
339
+ INSERT INTO {self.table_name} ({columns},id)
339
340
  VALUES ({placeholders},?)
341
+ ON CONFLICT(id) DO UPDATE SET {set_clause}
340
342
  """
341
343
 
342
344
  def _prepare_item(self, item: SchemaType) -> Tuple[str, List[Any]]:
@@ -256,6 +256,15 @@ async def close_shared_client() -> None:
256
256
  _domain_clients.clear()
257
257
 
258
258
 
259
+ async def cleanup_all() -> None:
260
+ """Close all global HTTP resources (domain clients + cffi session)."""
261
+ await close_shared_client()
262
+ if _get_session_cffi.cache_info().currsize > 0:
263
+ cffi_session = _get_session_cffi()
264
+ await cffi_session.close()
265
+ _get_session_cffi.cache_clear()
266
+
267
+
259
268
  async def close_domain_client(url: str, http2: Optional[bool] = None) -> None:
260
269
  """Close HTTP client for a specific domain. If http2 is None, closes both h1 and h2 clients."""
261
270
  domain = _extract_domain(url)
@@ -379,7 +379,7 @@ async def test_prepare_item_dedup(temp_db):
379
379
  try:
380
380
  item = TestItem(name="test", value=5)
381
381
  sql, values = db._prepare_item(item)
382
- assert "INSERT OR REPLACE" in sql
382
+ assert "ON CONFLICT(id) DO UPDATE SET" in sql
383
383
  assert "test" in values
384
384
  assert 5 in values
385
385
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esuls
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Utility library for async database operations, HTTP requests, and parallel execution
5
5
  Author-email: IperGiove <ipergiove@gmail.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes