Qwael 3.9.8__tar.gz → 3.9.9__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: Qwael
3
- Version: 3.9.8
3
+ Version: 3.9.9
4
4
  Summary: Qwael: İşlevsel ve kolaylaştırılmış Python kütüphanesi
5
5
  Author: Bedirhan
6
6
  Author-email: bedirhan.oytpass@gmail.com
@@ -0,0 +1,116 @@
1
+ import mysql.connector
2
+
3
+ class Admin:
4
+ def __init__(self, IP, name, password, file_name, port=3306):
5
+ self.host = IP
6
+ self.user = name
7
+ self.password = password
8
+ self.database = file_name
9
+ self.port = port
10
+
11
+ try:
12
+ self.conn = mysql.connector.connect(
13
+ host=self.host,
14
+ user=self.user,
15
+ password=self.password,
16
+ database=self.database,
17
+ port=self.port
18
+ )
19
+ self.cursor = self.conn.cursor(dictionary=True)
20
+ print("Database connected!")
21
+ except mysql.connector.Error as e:
22
+ print("Connection Error:", e)
23
+
24
+ # ------------------------------------------------------
25
+ # INSERT (db.add)
26
+ # ------------------------------------------------------
27
+ def add(self, table, **kwargs):
28
+ keys = ", ".join(kwargs.keys())
29
+ values = ", ".join(["%s"] * len(kwargs))
30
+ sql = f"INSERT INTO {table} ({keys}) VALUES ({values})"
31
+
32
+ try:
33
+ self.cursor.execute(sql, tuple(kwargs.values()))
34
+ self.conn.commit()
35
+ print("Added!")
36
+ except mysql.connector.Error as e:
37
+ print("Insert Error:", e)
38
+
39
+ # ------------------------------------------------------
40
+ # UPDATE (db.update("users", {"ID": 3}, {"name": "Ali"}))
41
+ # ------------------------------------------------------
42
+ def update(self, table, where: dict, data: dict):
43
+ set_clause = ", ".join([f"{k}=%s" for k in data])
44
+ where_clause = " AND ".join([f"{k}=%s" for k in where])
45
+
46
+ values = list(data.values()) + list(where.values())
47
+ sql = f"UPDATE {table} SET {set_clause} WHERE {where_clause}"
48
+
49
+ try:
50
+ self.cursor.execute(sql, values)
51
+ self.conn.commit()
52
+ print("Updated!")
53
+ except mysql.connector.Error as e:
54
+ print("Update Error:", e)
55
+
56
+ # ------------------------------------------------------
57
+ # DELETE (db.delete("users", ID=3))
58
+ # ------------------------------------------------------
59
+ def delete(self, table, **kwargs):
60
+ where_clause = " AND ".join([f"{k}=%s" for k in kwargs])
61
+ sql = f"DELETE FROM {table} WHERE {where_clause}"
62
+
63
+ try:
64
+ self.cursor.execute(sql, tuple(kwargs.values()))
65
+ self.conn.commit()
66
+ print("Deleted!")
67
+ except mysql.connector.Error as e:
68
+ print("Delete Error:", e)
69
+
70
+ # ------------------------------------------------------
71
+ # GET (tek veri) — db.get("users", ID=3, Variable=veri)
72
+ # ------------------------------------------------------
73
+ def get(self, table, **kwargs):
74
+ external_var = None
75
+
76
+ # Variable parametresini dışarı al
77
+ if "Variable" in kwargs:
78
+ external_var = kwargs["Variable"]
79
+ kwargs.pop("Variable") # filtrelerden çıkar
80
+
81
+ # WHERE oluştur
82
+ where_clause = " AND ".join([f"{k}=%s" for k in kwargs])
83
+ sql = f"SELECT * FROM {table} WHERE {where_clause} LIMIT 1"
84
+
85
+ try:
86
+ self.cursor.execute(sql, tuple(kwargs.values()))
87
+ row = self.cursor.fetchone()
88
+
89
+ if row:
90
+ # Variable={} gönderilmişse doldur
91
+ if external_var is not None:
92
+ external_var.clear()
93
+ external_var.update(row)
94
+
95
+ print("Data found:", row)
96
+ return row
97
+
98
+ print("No data found.")
99
+ return None
100
+
101
+ except mysql.connector.Error as e:
102
+ print("Get Error:", e)
103
+
104
+ # ------------------------------------------------------
105
+ # GET ALL (db.get_all("users"))
106
+ # ------------------------------------------------------
107
+ def get_all(self, table):
108
+ sql = f"SELECT * FROM {table}"
109
+
110
+ try:
111
+ self.cursor.execute(sql)
112
+ rows = self.cursor.fetchall()
113
+ return rows
114
+ except mysql.connector.Error as e:
115
+ print("Get All Error:", e)
116
+ return []
@@ -5,4 +5,5 @@ from .DRİVE import delete
5
5
  from .DRİVE import get
6
6
  from .DoIP import IP
7
7
  from .filesz import EasyDB
8
- from .MultiDB import MultiDB
8
+ from .MultiDB import MultiDB
9
+ from .Multidata import Multidata
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Qwael
3
- Version: 3.9.8
3
+ Version: 3.9.9
4
4
  Summary: Qwael: İşlevsel ve kolaylaştırılmış Python kütüphanesi
5
5
  Author: Bedirhan
6
6
  Author-email: bedirhan.oytpass@gmail.com
@@ -4,6 +4,7 @@ setup.py
4
4
  Qwael/DRİVE.py
5
5
  Qwael/DoIP.py
6
6
  Qwael/MultiDB.py
7
+ Qwael/Multidata.py
7
8
  Qwael/__init__.py
8
9
  Qwael/filesz.py
9
10
  Qwael.egg-info/PKG-INFO
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="Qwael",
8
- version="3.9.8",
8
+ version="3.9.9",
9
9
  packages=find_packages(),
10
10
  install_requires=[
11
11
  "google-api-python-client",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes