sqlthon 0.1.0__tar.gz → 0.1.2__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.1.0
3
+ Version: 0.1.2
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.1.0'
7
+ version = '0.1.2'
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 *
16
+
17
+ __all__ = ['Field', 'Connect', 'SqlthonError', 'YouHackerError', 'TableError', 'TableNotFoundError', 'TableAlreadyExistsError', 'ColumnError', 'ColumnNotFoundError', 'RecordError', 'UniqueConstraintError', 'NotNullConstraintError', 'DataTypeError', 'ForeignKeyError', 'CheckConstraintError', 'PrimaryKeyError', 'QueryError', 'SyntaxError', 'NoSuchFunctionError', 'WrongNumberOfArgumentsError', 'DatabaseError', 'DatabaseLockedError', 'DatabaseReadOnlyError', 'DatabaseCorruptError', 'DatabaseFullError', 'DatabaseBusyError', 'IndexError', 'IndexNotFoundError', 'IndexAlreadyExistsError', 'ViewError', 'ViewNotFoundError', 'ViewAlreadyExistsError', 'TransactionError', 'TransactionAlreadyActiveError', 'TransactionNotActiveError', 'BackupError', 'BackupPathError', 'BackupPermissionError', 'CsvError', 'CsvFileNotFoundError', 'CsvFormatError', 'PandasError', 'PandasNotInstalledError', 'ValidationError', 'InvalidColumnCountError', 'InvalidValueError']
18
+ __version__ = '0.1.2'
19
+ __author__ = "SAUMS"
20
+ __email__ = "saums1391@gmail.com"
21
+ __description__ = "Operate With SQLite3 Buy Simple"
@@ -99,8 +99,15 @@ def _analysis_code(query):
99
99
  for i in query:
100
100
  _analysis_code(i)
101
101
  return
102
- if not match("^[A-Za-z_][A-Za-z0-9_.(), ]*$", query) or "sqlite_" in query.lower():
103
- raise YouHackerError(f"you hacker for {query!r}.") from None
102
+ if not match("^[A-Za-z_][A-Za-z0-9_.(), ]*$", query) or any(word in query.lower() for word in ("sqlite_", "union", "select", "blob", "pragma")):
103
+ for i in {"NOT", "NULL", "PRIMARY", "KEY", "UNIQUE", "DEFAULT",
104
+ "CHECK", "AUTOINCREMENT", "REFERENCES", "COLLATE",
105
+ "TRUE", "FALSE", "CURRENT_TIMESTAMP", "ON", "DELETE",
106
+ "UPDATE", "CASCADE", "RESTRICT", "SET", "NO", "ACTION",
107
+ "PRECISION", "DOUBLE", "UNSIGNED", "BIG", "INT",
108
+ "NATIVE", "CHARACTER", "VARYING",}:
109
+ if not i in query:
110
+ raise YouHackerError(f"you hacker for {query!r}.") from None
104
111
 
105
112
 
106
113
  class Connect:
@@ -125,7 +132,7 @@ class Connect:
125
132
  name, type = column[0], column[1]
126
133
  try:
127
134
  limits = column[2]
128
- query += f"{name} {type} {" ".join(limits)}"
135
+ query += f"""{name} {type} {" ".join(limits)}"""
129
136
  except:
130
137
  query += f"{name} {type}"
131
138
 
@@ -195,7 +202,7 @@ class Connect:
195
202
  query += "DISTINCT "
196
203
  if columns:
197
204
  _analysis_code(columns)
198
- query += f"{', '.join(columns) if columns else '*'} FROM {table_name}"
205
+ query += f"""{", ".join(columns) if columns else "*"} FROM {table_name}"""
199
206
  if compound:
200
207
  if compound[0].upper() not in ("INNER", "LEFT"):
201
208
  raise YouHackerError(f"you hacker for {query!r}.") from None
@@ -234,12 +241,12 @@ class Connect:
234
241
 
235
242
  def add_record(self, table_name: str, record_info: tuple) -> None:
236
243
  _analysis_code(table_name)
237
- self._changes.append((f"INSERT INTO {table_name} VALUES({', '.join(['?']*len(record_info))})", record_info))
244
+ self._changes.append((f"""INSERT INTO {table_name} VALUES({", ".join(["?"]*len(record_info))})""", record_info))
238
245
 
239
246
  def add_records(self, table_name: str, info_records: tuple) -> None:
240
247
  _analysis_code(table_name)
241
248
  try:
242
- self._cur.executemany(f"INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_records[0]))})", info_records)
249
+ self._cur.executemany(f"""INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_records[0]))})""", info_records)
243
250
  self._con.commit()
244
251
  except Exception as e:
245
252
  _handler_error(e)
@@ -281,7 +288,7 @@ class Connect:
281
288
  def upsert_record(self, table_name: str, info_record: tuple, conflict: tuple) -> None:
282
289
  _analysis_code(table_name)
283
290
  _analysis_code(conflict)
284
- query = f"INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_record))}) ON CONFLICT(\"{'", "'.join(conflict)}\") DO UPDATE SET "
291
+ query = f"""INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_record))}) ON CONFLICT(\"{'", "'.join(conflict)}\") DO UPDATE SET """
285
292
  param = info_record
286
293
  colue = dict(zip(self.get_columns(table_name), info_record)) # columns value
287
294
  for i in conflict:
@@ -368,7 +375,7 @@ class Connect:
368
375
  if not abspath(csv_path).startswith(allowed_dir):
369
376
  raise YouHackerError(f"you hacker for {csv_path!r}.")
370
377
  import csv as _csv
371
- with open(csv_path, "w", newline="", encoding="utf-8") as f:
378
+ with open(csv_path, "w") as f:
372
379
  writer = _csv.writer(f)
373
380
  writer.writerow(self.get_columns(table_name))
374
381
  for row in self.find_record(table_name):
@@ -401,11 +408,9 @@ class Connect:
401
408
  with self._con:
402
409
  for sql_code in self._changes:
403
410
  self._cur.execute(*sql_code)
411
+ self._changes.clear()
404
412
  except Exception as e:
405
413
  _handler_error(e)
406
-
407
- finally:
408
- self._changes.clear()
409
414
 
410
415
  def close(self):
411
416
  self._con.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlthon
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A simple package for SQLite3 operations
5
5
  Author-email: SAUMS <mohamnown@gmail.com>
6
6
  License: MIT
@@ -1,21 +0,0 @@
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.1.0'
19
- __author__ = "SAUMS"
20
- __email__ = "saums1391@gmail.com"
21
- __description__ = "Operate With SQLite3 Buy Simple"
File without changes
File without changes
File without changes