sqlthon 0.1.5__tar.gz → 1.0.0__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.
sqlthon-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlthon
3
+ Version: 1.0.0
4
+ Summary: A simple package for SQLite3 operations
5
+ Author-email: SAUMS <supportsqlthon@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/SAUMS-1391/sqlthon
8
+ Project-URL: Repository, https://github.com/SAUMS-1391/sqlthon
9
+ Project-URL: Documentation, https://sqlthon.readthedocs.io/
10
+ Project-URL: Issues, https://github.com/SAUMS-1391/sqlthon/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Sqlthon
18
+
19
+ A powerful, Pythonic layer for SQLite3 — built for developers who don't know SQL.
20
+
21
+ ## Why Sqlthon?
22
+
23
+ SQLite is powerful, but using it requires knowing SQL. Sqlthon lets you work with SQLite databases using **pure Python objects and methods** — no SQL queries needed. Just define your tables and fields, and Sqlthon handles the rest.
24
+
25
+ **Sqlthon is:**
26
+ - ✅ A powerful layer for working with SQLite3 in pure Python
27
+ - ✅ Built for developers who don't know SQL
28
+ - ✅ Suitable for real projects and production use
29
+
30
+ **Sqlthon is NOT:**
31
+ - ❌ A replacement for the built-in `sqlite3` module
32
+ - ❌ A toy package for tiny scripts
33
+ - ❌ Feature-complete yet — it's under active development
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install sqlthon
@@ -0,0 +1,22 @@
1
+ # Sqlthon
2
+
3
+ A powerful, Pythonic layer for SQLite3 — built for developers who don't know SQL.
4
+
5
+ ## Why Sqlthon?
6
+
7
+ SQLite is powerful, but using it requires knowing SQL. Sqlthon lets you work with SQLite databases using **pure Python objects and methods** — no SQL queries needed. Just define your tables and fields, and Sqlthon handles the rest.
8
+
9
+ **Sqlthon is:**
10
+ - ✅ A powerful layer for working with SQLite3 in pure Python
11
+ - ✅ Built for developers who don't know SQL
12
+ - ✅ Suitable for real projects and production use
13
+
14
+ **Sqlthon is NOT:**
15
+ - ❌ A replacement for the built-in `sqlite3` module
16
+ - ❌ A toy package for tiny scripts
17
+ - ❌ Feature-complete yet — it's under active development
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install sqlthon
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sqlthon"
7
- version = '0.1.5'
7
+ version = '1.0.0'
8
8
  description = "A simple package for SQLite3 operations"
9
9
  readme = "README.md"
10
- requires-python = ">=3.8"
10
+ requires-python = ">=3.10"
11
11
  license = {text = "MIT"}
12
12
  authors = [
13
- {name = "SAUMS", email = "mohamnown@gmail.com"}
13
+ {name = "SAUMS", email = "supportsqlthon@gmail.com"}
14
14
  ]
15
15
  classifiers = [
16
16
  "Programming Language :: Python :: 3",
@@ -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/Sqlthon
12
+ """
13
+
14
+ from .core import Connect, Field
15
+
16
+ __all__ = ['Field', 'Connect']
17
+
18
+ __version__ = '1.0.0'
19
+ __author__ = "SAUMS"
20
+ __email__ = "supportsqlthon@gmail.com"
21
+ __description__ = "A Simple Package For SQLite3 Operations."
@@ -1,113 +1,4 @@
1
- class Field:
2
- __slots__ = ("name",)
3
- def __init__(self, name):
4
- _analysis_code(name)
5
- self.name = name
6
-
7
- def __gt__(self, value): return _Expression(self, ">", value)
8
- def __lt__(self, value): return _Expression(self, "<", value)
9
- def __ge__(self, value): return _Expression(self, ">=", value)
10
- def __le__(self, value): return _Expression(self, "<=", value)
11
- def __eq__(self, value): return _Expression(self, "=", value)
12
- def __ne__(self, value): return _Expression(self, "!=", value)
13
- def __invert__(self): return _Expression(self, "NOT", None)
14
- def not_like(self, value): return _Expression(self, "NOT LIKE", value)
15
- def like(self, value):
16
- return _Expression(self, "LIKE", value)
17
- def startswith(self, value):
18
- return _Expression(self, "LIKE", f"{value}%")
19
- def endswith(self, value):
20
- return _Expression(self, "LIKE", f"%{value}")
21
- def contains(self, value):
22
- return _Expression(self, "LIKE", f"%{value}%")
23
- def in_(self, value):
24
- return _Expression(self, "IN", value)
25
- def not_in(self, value):
26
- return _Expression(self, "NOT IN", value)
27
- def between(self, value):
28
- return _Expression(self, "BETWEEN", value)
29
- def is_null(self):
30
- return _Expression(self, "IS NULL", None)
31
- def is_not_null(self):
32
- return _Expression(self, "IS NOT NULL", None)
33
-
34
-
35
- class _Expression:
36
- __slots__ = ("left", "op", "right")
37
- def __init__(self, left, op, right):
38
- self.left = left
39
- self.op = op
40
- self.right = right
41
-
42
- def __and__(self, other):
43
- return _Expression(self, "AND", other)
44
- def __or__(self, other):
45
- return _Expression(self, "OR", other)
46
-
47
-
48
- class _Aggregate:
49
- __slots__ = ("func", "column")
50
- def __init__(self, func, column="*"):
51
- if not column == "*":
52
- _analysis_code(column)
53
- self.func = func
54
- self.column = column
55
-
56
- def __gt__(self, value): return _Expression(self, ">", value)
57
- def __lt__(self, value): return _Expression(self, "<", value)
58
- def __ge__(self, value): return _Expression(self, ">=", value)
59
- def __le__(self, value): return _Expression(self, "<=", value)
60
- def __eq__(self, value): return _Expression(self, "=", value)
61
- def __ne__(self, value): return _Expression(self, "!=", value)
62
-
63
- def __str__(self):
64
- return f"{self.func}({self.column})"
65
-
66
-
67
- def _compile(expr):
68
- if isinstance(expr.left, _Expression) or isinstance(expr.right, _Expression):
69
- left_sql, left_params = _compile(expr.left)
70
- right_sql, right_params = _compile(expr.right)
71
- sql = f"({left_sql}) {expr.op} ({right_sql})"
72
- params = left_params + right_params
73
- return sql, params
74
- elif expr.op in ("IN", "NOT IN"):
75
- placeholders = ", ".join(["?"] * len(expr.right))
76
- sql = f'"{expr.left.name}" {expr.op} ({placeholders})'
77
- params = tuple(expr.right)
78
- return sql, params
79
- elif expr.op == "BETWEEN":
80
- sql = f'"{expr.left.name}" BETWEEN ? AND ?'
81
- params = tuple(expr.right)
82
- return sql, params
83
- elif expr.op in ("IS NULL", "IS NOT NULL"):
84
- sql = f'"{expr.left.name}" {expr.op}'
85
- return sql, ()
86
- elif isinstance(expr.left, _Aggregate):
87
- sql = f"{expr.left} {expr.op} ?"
88
- params = (expr.right,)
89
- return sql, params
90
- else:
91
- sql = f'"{expr.left.name}" {expr.op} ?'
92
- params = (expr.right,)
93
- return sql, params
94
-
95
-
96
- def _analysis_code(query):
97
- from re import match
98
- if isinstance(query, (list, tuple)):
99
- for i in query:
100
- _analysis_code(i)
101
- return
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
1
+ from .errors import (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)
111
2
 
112
3
 
113
4
  class Connect:
@@ -123,6 +14,8 @@ class Connect:
123
14
  # ____________| TABLE |____________
124
15
  def add_table(self, table_name: str, *columns: tuple, if_not_exists=False) -> None:
125
16
  _analysis_code(table_name)
17
+ if not columns:
18
+ raise TypeError("at least one column must be specified.") from None
126
19
  query = "CREATE TABLE "
127
20
  if if_not_exists:
128
21
  query += "IF NOT EXISTS "
@@ -165,9 +58,12 @@ class Connect:
165
58
  def add_column(self, table_name: str, column_name: str, column_type: str, limits: list | str=[]) -> None:
166
59
  _analysis_code(table_name)
167
60
  _analysis_code(column_name)
168
- _analysis_code(column_type)
61
+ if column_type.count(" ") > 2 or "--" in column_type or "/*" in column_type:
62
+ raise YouHackerError(f"you hacker for {column_type!r}.") from None
169
63
  if limits:
170
- _analysis_code(limits)
64
+ for limit in limits:
65
+ if "--" in limit:
66
+ raise YouHackerError(f"you hacker for {limit!r}.") from None
171
67
  limits = " ".join(limits)
172
68
  else:
173
69
  limits = ""
@@ -215,7 +111,7 @@ class Connect:
215
111
  del _
216
112
  if bundle:
217
113
  _analysis_code(bundle)
218
- query += f" GROUP BY {", ".join(bundle)}"
114
+ query += f' GROUP BY {", ".join(bundle)}'
219
115
  if filter_bundle:
220
116
  __: tuple = _compile(filter_bundle)
221
117
  query += f" HAVING {__[0]}"
@@ -293,17 +189,25 @@ class Connect:
293
189
  colue = dict(zip(self.get_columns(table_name), info_record)) # columns value
294
190
  for i in conflict:
295
191
  del colue[i]
296
- for key, value in colue.items():
297
- query += f'"{key}"=?, '
298
- param += (value,)
299
- query = query[:-2]
192
+ if colue:
193
+ for key, value in colue.items():
194
+ query += f'"{key}"=?, '
195
+ param += (value,)
196
+ query = query[:-2]
197
+ else:
198
+ query = query.replace(" DO UPDATE SET", " DO NOTHING")
300
199
  self._changes.append((query, param))
301
200
 
302
201
  # ____________| INDEX |_________
303
202
  def add_index(self, table_name: str, column_name: str, unique: bool=False) -> None:
304
203
  _analysis_code(table_name)
305
204
  _analysis_code(column_name)
306
- self._changes.append((f"CREATE INDEX{" UNIQUE" if unique else ""} {table_name}_{column_name} ON {table_name} ({column_name})",))
205
+
206
+ self._changes.append((
207
+ f"CREATE {'UNIQUE ' if unique else ''}INDEX "
208
+ f"{table_name}_{column_name} ON "
209
+ f"{table_name} ({column_name})",
210
+ ))
307
211
 
308
212
  def delete_index(self, table_name: str, column_name: str) -> None:
309
213
  _analysis_code(table_name)
@@ -312,7 +216,8 @@ class Connect:
312
216
 
313
217
  # ____________| VIEW |_________
314
218
  def add_view(self, view_name: str, query: str) -> None:
315
- raise YouHackerError("add_view is disabled for security reasons.")
219
+ _analysis_code(view_name)
220
+ self._changes.append((f"CREATE VIEW {view_name} AS {query}",))
316
221
 
317
222
  def delete_view(self, view_name: str) -> None:
318
223
  _analysis_code(view_name)
@@ -323,22 +228,19 @@ class Connect:
323
228
  return view_name in [i[0] for i in self._cur.execute("SELECT name FROM sqlite_master WHERE type='view'").fetchall()]
324
229
 
325
230
  # ____________| BACKUP |_________
326
- def backup_database(self, backup_path: str | None=None) -> None:
327
- from shutil import copy2
328
- from os.path import abspath, dirname, join
329
- self._con.commit()
330
- allowed_dir = dirname(abspath(self._path))
331
- if backup_path:
332
- if not abspath(backup_path).startswith(allowed_dir):
333
- raise YouHackerError(f"you hacker for {backup_path!r}.")
334
- copy2(self._path, backup_path)
335
- else:
336
- copy2(self._path, join(allowed_dir, "backup.db"))
231
+ def backup_database(self, backup_path: str) -> None:
232
+ self.save_to_database()
233
+ import sqlite3
234
+ with sqlite3.connect(backup_path) as target:
235
+ self._con.backup(target)
337
236
 
338
237
  # ____________| PANDAS |_________
339
238
  def to_dataframe(self, table_name: str) -> "pd.DataFrame":
340
239
  _analysis_code(table_name)
341
- import pandas as pd
240
+ try:
241
+ import pandas as pd
242
+ except:
243
+ raise PandasNotInstalledError("you have not installed the pandas package yet.")
342
244
  columns = self.get_columns(table_name)
343
245
  result = self._cur.execute(f"SELECT * FROM {table_name}").fetchall()
344
246
  return pd.DataFrame(result, columns=columns)
@@ -396,7 +298,12 @@ class Connect:
396
298
 
397
299
  # ____________| BASIC |_________
398
300
  def run_query(self, code: str, parameters: tuple=()) -> list:
399
- raise YouHackerError("run_query is disabled for security reasons.")
301
+ try:
302
+ self._cur.execute(code, parameters)
303
+ except Exception as e:
304
+ _handler_error(e)
305
+ self._con.commit()
306
+ return self._cur.fetchall()
400
307
 
401
308
  def optimize(self) -> None:
402
309
  self.save_to_database()
@@ -419,67 +326,160 @@ class Connect:
419
326
  def __enter__(self) -> "Connect":
420
327
  return self
421
328
 
422
- def __exit__(self, exc_type, exc_value, exc_tb) -> None:
423
- self.save_to_database()
424
- self.close()
329
+ def __exit__(self, exc_type, exc_value, traceback) -> bool:
330
+ try:
331
+ if exc_type is None:
332
+ self.save_to_database()
333
+ else:
334
+ self._changes.clear()
335
+ self._con.rollback()
336
+ finally:
337
+ self.close()
338
+
339
+ return False
425
340
 
426
341
 
427
- # ____________| ERRORS |_________
428
- class SqlthonError(Exception):__module__ = None
429
- class YouHackerError(SqlthonError, PermissionError):__module__ = None
430
- class TableError(SqlthonError):__module__ = None
431
- class TableNotFoundError(TableError):__module__ = None
432
- class TableAlreadyExistsError(TableError):__module__ = None
433
- class ColumnError(SqlthonError):__module__ = None
434
- class ColumnNotFoundError(ColumnError):__module__ = None
435
- class RecordError(SqlthonError):__module__ = None
436
- class UniqueConstraintError(RecordError):__module__ = None
437
- class NotNullConstraintError(RecordError):__module__ = None
438
- class DataTypeError(RecordError):__module__ = None
439
- class ForeignKeyError(RecordError):__module__ = None
440
- class CheckConstraintError(RecordError):__module__ = None
441
- class PrimaryKeyError(RecordError):__module__ = None
442
- class QueryError(SqlthonError):__module__ = None
443
- class SyntaxError_(QueryError):__module__ = None
444
- class NoSuchFunctionError(QueryError):__module__ = None
445
- class WrongNumberOfArgumentsError(QueryError):__module__ = None
446
- class DatabaseError(SqlthonError):__module__ = None
447
- class DatabaseLockedError(DatabaseError):__module__ = None
448
- class DatabaseReadOnlyError(DatabaseError):__module__ = None
449
- class DatabaseCorruptError(DatabaseError):__module__ = None
450
- class DatabaseFullError(DatabaseError):__module__ = None
451
- class DatabaseBusyError(DatabaseError):__module__ = None
452
- class IndexError_(SqlthonError):__module__ = None
453
- class IndexNotFoundError(IndexError):__module__ = None
454
- class IndexAlreadyExistsError(IndexError):__module__ = None
455
- class ViewError(SqlthonError):__module__ = None
456
- class ViewNotFoundError(ViewError):__module__ = None
457
- class ViewAlreadyExistsError(ViewError):__module__ = None
458
- class TransactionError(SqlthonError):__module__ = None
459
- class TransactionAlreadyActiveError(TransactionError):__module__ = None
460
- class TransactionNotActiveError(TransactionError):__module__ = None
461
- class BackupError(SqlthonError):__module__ = None
462
- class BackupPathError(BackupError):__module__ = None
463
- class BackupPermissionError(BackupError):__module__ = None
464
- class CsvError(SqlthonError):__module__ = None
465
- class CsvFileNotFoundError(CsvError):__module__ = None
466
- class CsvFormatError(CsvError):__module__ = None
467
- class PandasError(SqlthonError):__module__ = None
468
- class PandasNotInstalledError(PandasError):__module__ = None
469
- class ValidationError(SqlthonError):__module__ = None
470
- class InvalidColumnCountError(ValidationError):__module__ = None
471
- class InvalidValueError(ValidationError):__module__ = None
342
+ class Field:
343
+ __slots__ = ("name",)
344
+ def __init__(self, name):
345
+ _analysis_code(name)
346
+ if "." in name:
347
+ name = name.replace(".", "\".\"")
348
+ self.name = name
349
+
350
+ def __gt__(self, value): return _Expression(self, ">", value)
351
+ def __lt__(self, value): return _Expression(self, "<", value)
352
+ def __ge__(self, value): return _Expression(self, ">=", value)
353
+ def __le__(self, value): return _Expression(self, "<=", value)
354
+ def __eq__(self, value): return _Expression(self, "=", value)
355
+ def __ne__(self, value): return _Expression(self, "!=", value)
356
+ def __invert__(self): return _Expression(self, "NOT", None)
357
+ def not_like(self, value): return _Expression(self, "NOT LIKE", value)
358
+ def like(self, value):
359
+ return _Expression(self, "LIKE", value)
360
+ def startswith(self, value):
361
+ return _Expression(self, "LIKE", f"{value}%")
362
+ def endswith(self, value):
363
+ return _Expression(self, "LIKE", f"%{value}")
364
+ def contains(self, value):
365
+ return _Expression(self, "LIKE", f"%{value}%")
366
+ def in_(self, value):
367
+ return _Expression(self, "IN", value)
368
+ def not_in(self, value):
369
+ return _Expression(self, "NOT IN", value)
370
+ def between(self, value):
371
+ return _Expression(self, "BETWEEN", value)
372
+ def is_null(self):
373
+ return _Expression(self, "IS NULL", None)
374
+ def is_not_null(self):
375
+ return _Expression(self, "IS NOT NULL", None)
376
+
377
+
378
+ class _Expression:
379
+ __slots__ = ("left", "op", "right")
380
+ def __init__(self, left, op, right):
381
+ self.left = left
382
+ self.op = op
383
+ self.right = right
384
+
385
+ def __and__(self, other):
386
+ return _Expression(self, "AND", other)
387
+ def __or__(self, other):
388
+ return _Expression(self, "OR", other)
389
+ def __invert__(self):
390
+ return _Expression(self, "NOT", None)
391
+
392
+
393
+ class _Aggregate:
394
+ __slots__ = ("func", "column")
395
+ def __init__(self, func, column="*"):
396
+ if not column == "*":
397
+ _analysis_code(column)
398
+ if func not in ("MAX", "MIN", "SUM", "AVG", "COUNT"):
399
+ raise YouHackerError(f"you hacker for {func!r}.")
400
+ self.func = func
401
+ self.column = column
402
+
403
+ def __gt__(self, value): return _Expression(self, ">", value)
404
+ def __lt__(self, value): return _Expression(self, "<", value)
405
+ def __ge__(self, value): return _Expression(self, ">=", value)
406
+ def __le__(self, value): return _Expression(self, "<=", value)
407
+ def __eq__(self, value): return _Expression(self, "=", value)
408
+ def __ne__(self, value): return _Expression(self, "!=", value)
409
+
410
+ def __str__(self):
411
+ return f"{self.func}({self.column})"
412
+
413
+
414
+ def _compile(expr):
415
+ if isinstance(expr.left, _Expression) or isinstance(expr.right, _Expression):
416
+ left_sql, left_params = _compile(expr.left)
417
+ right_sql, right_params = _compile(expr.right)
418
+ sql = f"({left_sql}) {expr.op} ({right_sql})"
419
+ params = left_params + right_params
420
+ return sql, params
421
+ elif expr.op in ("IN", "NOT IN"):
422
+ placeholders = ", ".join(["?"] * len(expr.right))
423
+ sql = f'"{expr.left.name}" {expr.op} ({placeholders})'
424
+ params = tuple(expr.right)
425
+ return sql, params
426
+ elif expr.op == "BETWEEN":
427
+ sql = f'"{expr.left.name}" BETWEEN ? AND ?'
428
+ params = tuple(expr.right)
429
+ return sql, params
430
+ elif expr.op == "NOT":
431
+ if isinstance(expr.left, Field):
432
+ return f'NOT ("{expr.left.name}")', ()
433
+ sql, params = _compile(expr.left)
434
+ return f"NOT ({sql})", params
435
+ elif expr.op in ("IS NULL", "IS NOT NULL"):
436
+ sql = f'"{expr.left.name}" {expr.op}'
437
+ return sql, ()
438
+ elif isinstance(expr.left, _Aggregate):
439
+ sql = f"{expr.left} {expr.op} ?"
440
+ params = (expr.right,)
441
+ return sql, params
442
+ else:
443
+ sql = f'"{expr.left.name}" {expr.op} ?'
444
+ params = (expr.right,)
445
+ return sql, params
472
446
 
473
447
 
448
+ def _analysis_code(query):
449
+ from re import match
450
+ if isinstance(query, (list, tuple)):
451
+ for i in query:
452
+ _analysis_code(i)
453
+ return
454
+ if query.startswith("CHECK "):
455
+ if match(r"^CHECK \([A-Za-z_][A-Za-z0-9_]*\s*(?:>=|<=|!=|=|>|<)\s*(?:-?\d+(?:\.\d+)?|'(?:[^']|'')*')\)$", query):
456
+ return
457
+ raise YouHackerError(f"you hacker for {query!r}.") from None
458
+ if match(r"^DEFAULT '[^']*'$", query) or query == "COUNT(*)":
459
+ return
460
+ elif not match(r"^[A-Za-z_][A-Za-z0-9_.(), ]*$", query) or any(
461
+ word in query.lower()
462
+ for word in ("sqlite_", "union", "select", "blob", "pragma")
463
+ ):
464
+ for i in {
465
+ "NOT", "NULL", "PRIMARY", "KEY", "UNIQUE", "DEFAULT",
466
+ "CHECK", "AUTOINCREMENT", "REFERENCES", "COLLATE",
467
+ "TRUE", "FALSE", "CURRENT_TIMESTAMP", "ON", "DELETE",
468
+ "UPDATE", "CASCADE", "RESTRICT", "SET", "NO", "ACTION",
469
+ "PRECISION", "DOUBLE", "UNSIGNED", "BIG", "INT",
470
+ "NATIVE", "CHARACTER", "VARYING",
471
+ }:
472
+ if not i in query:
473
+ raise YouHackerError(f"you hacker for {query!r}.") from None
474
+
475
+
476
+ # ____________| ERROR |_________
474
477
  def _handler_error(e: Exception):
475
478
  msg = str(e).lower()
476
479
 
477
480
  if "no such table" in msg:
478
481
  raise TableNotFoundError(f"no table with name {msg.split()[-1]!r}.") from None
479
482
 
480
- elif "already exists" in msg:
481
- raise TableAlreadyExistsError(f"table {msg.split()[1]!r} alredy existed.") from None
482
-
483
483
  elif "no such column" in msg:
484
484
  raise ColumnNotFoundError(f"no column with name {msg.split()[-1]!r}.") from None
485
485
 
@@ -543,5 +543,8 @@ def _handler_error(e: Exception):
543
543
  elif "no transaction is active" in msg:
544
544
  raise TransactionNotActiveError(msg) from None
545
545
 
546
+ elif "already exists" in msg:
547
+ raise TableAlreadyExistsError(f"table {msg.split()[1]!r} alredy existed.") from None
548
+
546
549
  else:
547
550
  raise SqlthonError(msg) from None
@@ -0,0 +1,44 @@
1
+ class SqlthonError(Exception):__module__ = ""
2
+ class YouHackerError(SqlthonError, PermissionError):__module__ = ""
3
+ class TableError(SqlthonError):__module__ = ""
4
+ class TableNotFoundError(TableError):__module__ = ""
5
+ class TableAlreadyExistsError(TableError):__module__ = ""
6
+ class ColumnError(SqlthonError):__module__ = ""
7
+ class ColumnNotFoundError(ColumnError):__module__ = ""
8
+ class RecordError(SqlthonError):__module__ = ""
9
+ class UniqueConstraintError(RecordError):__module__ = ""
10
+ class NotNullConstraintError(RecordError):__module__ = ""
11
+ class DataTypeError(RecordError):__module__ = ""
12
+ class ForeignKeyError(RecordError):__module__ = ""
13
+ class CheckConstraintError(RecordError):__module__ = ""
14
+ class PrimaryKeyError(RecordError):__module__ = ""
15
+ class QueryError(SqlthonError):__module__ = ""
16
+ class SyntaxError_(QueryError):__module__ = ""
17
+ class NoSuchFunctionError(QueryError):__module__ = ""
18
+ class WrongNumberOfArgumentsError(QueryError):__module__ = ""
19
+ class DatabaseError(SqlthonError):__module__ = ""
20
+ class DatabaseLockedError(DatabaseError):__module__ = ""
21
+ class DatabaseReadOnlyError(DatabaseError):__module__ = ""
22
+ class DatabaseCorruptError(DatabaseError):__module__ = ""
23
+ class DatabaseFullError(DatabaseError):__module__ = ""
24
+ class DatabaseBusyError(DatabaseError):__module__ = ""
25
+ class IndexError_(SqlthonError):__module__ = ""
26
+ class IndexNotFoundError(IndexError_):__module__ = ""
27
+ class IndexAlreadyExistsError(IndexError_):__module__ = ""
28
+ class ViewError(SqlthonError):__module__ = ""
29
+ class ViewNotFoundError(ViewError):__module__ = ""
30
+ class ViewAlreadyExistsError(ViewError):__module__ = ""
31
+ class TransactionError(SqlthonError):__module__ = ""
32
+ class TransactionAlreadyActiveError(TransactionError):__module__ = ""
33
+ class TransactionNotActiveError(TransactionError):__module__ = ""
34
+ class BackupError(SqlthonError):__module__ = ""
35
+ class BackupPathError(BackupError):__module__ = ""
36
+ class BackupPermissionError(BackupError):__module__ = ""
37
+ class CsvError(SqlthonError):__module__ = ""
38
+ class CsvFileNotFoundError(CsvError):__module__ = ""
39
+ class CsvFormatError(CsvError):__module__ = ""
40
+ class PandasError(SqlthonError):__module__ = ""
41
+ class PandasNotInstalledError(PandasError):__module__ = ""
42
+ class ValidationError(SqlthonError):__module__ = ""
43
+ class InvalidColumnCountError(ValidationError):__module__ = ""
44
+ class InvalidValueError(ValidationError):__module__ = ""
@@ -1,3 +1,4 @@
1
+ from .core import _Aggregate
1
2
  STR = "TEXT"
2
3
  INT = "INTEGER"
3
4
  FLOAT = "REAL"
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlthon
3
+ Version: 1.0.0
4
+ Summary: A simple package for SQLite3 operations
5
+ Author-email: SAUMS <supportsqlthon@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/SAUMS-1391/sqlthon
8
+ Project-URL: Repository, https://github.com/SAUMS-1391/sqlthon
9
+ Project-URL: Documentation, https://sqlthon.readthedocs.io/
10
+ Project-URL: Issues, https://github.com/SAUMS-1391/sqlthon/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Sqlthon
18
+
19
+ A powerful, Pythonic layer for SQLite3 — built for developers who don't know SQL.
20
+
21
+ ## Why Sqlthon?
22
+
23
+ SQLite is powerful, but using it requires knowing SQL. Sqlthon lets you work with SQLite databases using **pure Python objects and methods** — no SQL queries needed. Just define your tables and fields, and Sqlthon handles the rest.
24
+
25
+ **Sqlthon is:**
26
+ - ✅ A powerful layer for working with SQLite3 in pure Python
27
+ - ✅ Built for developers who don't know SQL
28
+ - ✅ Suitable for real projects and production use
29
+
30
+ **Sqlthon is NOT:**
31
+ - ❌ A replacement for the built-in `sqlite3` module
32
+ - ❌ A toy package for tiny scripts
33
+ - ❌ Feature-complete yet — it's under active development
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install sqlthon
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  src/sqlthon/__init__.py
4
4
  src/sqlthon/core.py
5
+ src/sqlthon/errors.py
5
6
  src/sqlthon/keywords.py
6
7
  src/sqlthon.egg-info/PKG-INFO
7
8
  src/sqlthon.egg-info/SOURCES.txt
sqlthon-0.1.5/PKG-INFO DELETED
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: sqlthon
3
- Version: 0.1.5
4
- Summary: A simple package for SQLite3 operations
5
- Author-email: SAUMS <mohamnown@gmail.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/SAUMS-1391/sqlthon
8
- Project-URL: Repository, https://github.com/SAUMS-1391/sqlthon
9
- Project-URL: Documentation, https://sqlthon.readthedocs.io/
10
- Project-URL: Issues, https://github.com/SAUMS-1391/sqlthon/issues
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Requires-Python: >=3.8
15
- Description-Content-Type: text/markdown
16
-
17
- # Sqlthon
18
-
19
- A simple package for SQLite3 operations.
20
-
21
- ## Installation
22
-
23
- ```bash
24
- pip install sqlthon
sqlthon-0.1.5/README.md DELETED
@@ -1,8 +0,0 @@
1
- # Sqlthon
2
-
3
- A simple package for SQLite3 operations.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pip install sqlthon
@@ -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 *
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.5'
19
- __author__ = "SAUMS"
20
- __email__ = "saums1391@gmail.com"
21
- __description__ = "Operate With SQLite3 Buy Simple"
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: sqlthon
3
- Version: 0.1.5
4
- Summary: A simple package for SQLite3 operations
5
- Author-email: SAUMS <mohamnown@gmail.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/SAUMS-1391/sqlthon
8
- Project-URL: Repository, https://github.com/SAUMS-1391/sqlthon
9
- Project-URL: Documentation, https://sqlthon.readthedocs.io/
10
- Project-URL: Issues, https://github.com/SAUMS-1391/sqlthon/issues
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Requires-Python: >=3.8
15
- Description-Content-Type: text/markdown
16
-
17
- # Sqlthon
18
-
19
- A simple package for SQLite3 operations.
20
-
21
- ## Installation
22
-
23
- ```bash
24
- pip install sqlthon
File without changes