sqlthon 0.0.11__tar.gz → 0.0.12__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.11
3
+ Version: 0.0.12
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.11'
7
+ version = '0.0.12'
8
8
  description = "A simple package for SQLite3 operations"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -0,0 +1,21 @@
1
+ """
2
+ A Simple Package For SQLite3 Operations.
3
+
4
+ ||||| |||| || |||||| || || |||||| || ||
5
+ || || || || || || || || || ||| ||
6
+ |||| || || || || |||||| || || ||||||
7
+ || |||| || || || || || || || |||
8
+ ||||| || |||||| || || || |||||| || ||
9
+
10
+ Github: https://Github.com/saums-1391/sqlthon
11
+ Channel: https://ble.ir/saums_channel
12
+
13
+ """
14
+
15
+ from .core import Connect, Field
16
+
17
+ __all__ = ['Connect', 'Field']
18
+ __version__ = '0.0.12'
19
+ __author__ = "SAUMS"
20
+ __email__ = "saums1391@gmail.com"
21
+ __description__ = "Operate With SQLite3 Buy Simple"
@@ -79,7 +79,7 @@ class Connect:
79
79
  try:
80
80
  limits = column[2]
81
81
  query += f"{name} {type} {" ".join(limits)}"
82
- except IndexError:
82
+ except:
83
83
  query += f"{name} {type}"
84
84
 
85
85
  query += ", "
@@ -139,8 +139,8 @@ class Connect:
139
139
  query += f" GROUP BY {", ".join(bundle)}"
140
140
  if filter_bundle:
141
141
  __: tuple = _compile(filter_bundle)
142
- query += f" HAVING {_[0]}"
143
- param += _[1]
142
+ query += f" HAVING {__[0]}"
143
+ param += __[1]
144
144
  del __
145
145
 
146
146
  if sort:
@@ -250,10 +250,16 @@ class Connect:
250
250
  records = []
251
251
  for row in reader:
252
252
  records.append(tuple(row))
253
+ if records:
254
+ self.add_records(table_name, tuple(records))
253
255
 
254
- self.add_records(table_name, tuple(records))
255
-
256
-
256
+ def to_csv(self, table_name: str, csv_path: str) -> None:
257
+ import csv as _csv
258
+ with open(csv_path, "w", newline="", encoding="utf-8") as f:
259
+ writer = _csv.writer(f)
260
+ writer.writerow(self.get_columns(table_name))
261
+ for row in self.find_record(table_name):
262
+ writer.writerow(row)
257
263
  # ____________| OTHER |_________
258
264
  def last_id(self) -> int:
259
265
  return self.run_query("SELECT last_insert_rowid()")[0][0]
@@ -284,4 +290,12 @@ class Connect:
284
290
  self._changes.clear()
285
291
 
286
292
  def close(self):
287
- self._con.close()
293
+ self._con.close()
294
+
295
+ # ____________| MAGICALS |_________
296
+ def __enter__(self) -> "Connect":
297
+ return self
298
+
299
+ def __exit__(self, exc_type, exc_value, exc_tb) -> None:
300
+ self.save_to_database()
301
+ self.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlthon
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: A simple package for SQLite3 operations
5
5
  Author-email: SAUMS <mohamnown@gmail.com>
6
6
  License: MIT
@@ -1,11 +0,0 @@
1
- """
2
- Sqlthon - A Simple Package For SQLite3 Operations.
3
- """
4
-
5
- from .core import Connect, Field
6
-
7
- __all__ = ['Connect', 'Field']
8
- __version__ = '0.0.11'
9
- __author__ = "SAUMS"
10
- __email__ = "saums1391@gmail.com"
11
- __description__ = "Operate With SQLite3 Buy Simple"
File without changes
File without changes