sqlthon 0.0.12__tar.gz → 0.0.13__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: sqlthon
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: A simple package for SQLite3 operations
5
5
  Author-email: SAUMS <mohamnown@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sqlthon"
7
- version = '0.0.12'
7
+ version = '0.0.13'
8
8
  description = "A simple package for SQLite3 operations"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -15,7 +15,7 @@ Channel: https://ble.ir/saums_channel
15
15
  from .core import Connect, Field
16
16
 
17
17
  __all__ = ['Connect', 'Field']
18
- __version__ = '0.0.12'
18
+ __version__ = '0.0.13'
19
19
  __author__ = "SAUMS"
20
20
  __email__ = "saums1391@gmail.com"
21
21
  __description__ = "Operate With SQLite3 Buy Simple"
@@ -45,7 +45,7 @@ def _compile(expr):
45
45
  if isinstance(expr.left, _Expression) or isinstance(expr.right, _Expression):
46
46
  left_sql, left_params = _compile(expr.left)
47
47
  right_sql, right_params = _compile(expr.right)
48
- sql = f"{left_sql} {expr.op} {right_sql}"
48
+ sql = f"({left_sql}) {expr.op} ({right_sql})"
49
49
  params = left_params + right_params
50
50
  return sql, params
51
51
  elif isinstance(expr.left, _Aggregate):
@@ -275,7 +275,8 @@ class Connect:
275
275
  # ____________| BASIC |_________
276
276
  def run_query(self, code: str, parameters: tuple=()) -> list:
277
277
  self._cur.execute(code, parameters)
278
- self._con.commit()
278
+ if not "SELECT" in code:
279
+ self._con.commit()
279
280
  return self._cur.fetchall()
280
281
 
281
282
  def optimize(self) -> None:
@@ -284,10 +285,12 @@ class Connect:
284
285
  self._con.commit()
285
286
 
286
287
  def save_to_database(self) -> None:
287
- with self._con:
288
- for sql_code in self._changes:
289
- self._cur.execute(*sql_code)
290
- self._changes.clear()
288
+ try:
289
+ with self._con:
290
+ for sql_code in self._changes:
291
+ self._cur.execute(*sql_code)
292
+ finally:
293
+ self._changes.clear()
291
294
 
292
295
  def close(self):
293
296
  self._con.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlthon
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: A simple package for SQLite3 operations
5
5
  Author-email: SAUMS <mohamnown@gmail.com>
6
6
  License: MIT
File without changes
File without changes