Qwael 4.0.0.0.2__tar.gz → 4.0.0.0.4__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.
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/PKG-INFO +1 -1
- qwael-4.0.0.0.4/Qwael/Multidata.py +271 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael.egg-info/PKG-INFO +1 -1
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/setup.py +1 -1
- qwael-4.0.0.0.2/Qwael/Multidata.py +0 -116
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/LICENSE +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael/DR/304/260VE.py" +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael/DoIP.py +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael/MultiDB.py +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael/__init__.py +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael/filesz.py +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael.egg-info/SOURCES.txt +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael.egg-info/dependency_links.txt +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael.egg-info/requires.txt +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/Qwael.egg-info/top_level.txt +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/README.md +0 -0
- {qwael-4.0.0.0.2 → qwael-4.0.0.0.4}/setup.cfg +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
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
|
+
# ADD
|
|
26
|
+
# ------------------------------------------------------
|
|
27
|
+
def add(self, table, **kwargs):
|
|
28
|
+
external_control = None
|
|
29
|
+
|
|
30
|
+
if "Control" in kwargs:
|
|
31
|
+
external_control = kwargs["Control"]
|
|
32
|
+
kwargs.pop("Control")
|
|
33
|
+
|
|
34
|
+
keys = ", ".join(kwargs.keys())
|
|
35
|
+
values = ", ".join(["%s"] * len(kwargs))
|
|
36
|
+
sql = f"INSERT INTO {table} ({keys}) VALUES ({values})"
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
self.cursor.execute(sql, tuple(kwargs.values()))
|
|
40
|
+
self.conn.commit()
|
|
41
|
+
print("Added!")
|
|
42
|
+
if external_control is not None:
|
|
43
|
+
external_control.append(True)
|
|
44
|
+
return True
|
|
45
|
+
except mysql.connector.Error as e:
|
|
46
|
+
print("Insert Error:", e)
|
|
47
|
+
if external_control is not None:
|
|
48
|
+
external_control.append(False)
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
# ------------------------------------------------------
|
|
52
|
+
# UPDATE
|
|
53
|
+
# ------------------------------------------------------
|
|
54
|
+
def update(self, table, where: dict, data: dict, Control=None):
|
|
55
|
+
set_clause = ", ".join([f"{k}=%s" for k in data])
|
|
56
|
+
where_clause = " AND ".join([f"{k}=%s" for k in where])
|
|
57
|
+
|
|
58
|
+
values = list(data.values()) + list(where.values())
|
|
59
|
+
sql = f"UPDATE {table} SET {set_clause} WHERE {where_clause}"
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
self.cursor.execute(sql, values)
|
|
63
|
+
self.conn.commit()
|
|
64
|
+
print("Updated!")
|
|
65
|
+
if Control is not None:
|
|
66
|
+
Control.append(True)
|
|
67
|
+
return True
|
|
68
|
+
except mysql.connector.Error as e:
|
|
69
|
+
print("Update Error:", e)
|
|
70
|
+
if Control is not None:
|
|
71
|
+
Control.append(False)
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
# ------------------------------------------------------
|
|
75
|
+
# DELETE
|
|
76
|
+
# ------------------------------------------------------
|
|
77
|
+
def delete(self, table, **kwargs):
|
|
78
|
+
external_control = None
|
|
79
|
+
|
|
80
|
+
if "Control" in kwargs:
|
|
81
|
+
external_control = kwargs["Control"]
|
|
82
|
+
kwargs.pop("Control")
|
|
83
|
+
|
|
84
|
+
where_clause = " AND ".join([f"{k}=%s" for k in kwargs])
|
|
85
|
+
sql = f"DELETE FROM {table} WHERE {where_clause}"
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
self.cursor.execute(sql, tuple(kwargs.values()))
|
|
89
|
+
self.conn.commit()
|
|
90
|
+
print("Deleted!")
|
|
91
|
+
if external_control is not None:
|
|
92
|
+
external_control.append(True)
|
|
93
|
+
return True
|
|
94
|
+
except mysql.connector.Error as e:
|
|
95
|
+
print("Delete Error:", e)
|
|
96
|
+
if external_control is not None:
|
|
97
|
+
external_control.append(False)
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
# ------------------------------------------------------
|
|
101
|
+
# GET (tek veri)
|
|
102
|
+
# ------------------------------------------------------
|
|
103
|
+
def get(self, table, **kwargs):
|
|
104
|
+
external_var = None
|
|
105
|
+
external_control = None
|
|
106
|
+
|
|
107
|
+
if "Variable" in kwargs:
|
|
108
|
+
external_var = kwargs["Variable"]
|
|
109
|
+
kwargs.pop("Variable")
|
|
110
|
+
|
|
111
|
+
if "Control" in kwargs:
|
|
112
|
+
external_control = kwargs["Control"]
|
|
113
|
+
kwargs.pop("Control")
|
|
114
|
+
|
|
115
|
+
where_clause = " AND ".join([f"{k}=%s" for k in kwargs])
|
|
116
|
+
sql = f"SELECT * FROM {table} WHERE {where_clause} LIMIT 1"
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
self.cursor.execute(sql, tuple(kwargs.values()))
|
|
120
|
+
row = self.cursor.fetchone()
|
|
121
|
+
|
|
122
|
+
if row:
|
|
123
|
+
if external_var is not None:
|
|
124
|
+
external_var.clear()
|
|
125
|
+
external_var.update(row)
|
|
126
|
+
|
|
127
|
+
if external_control is not None:
|
|
128
|
+
external_control.append(True)
|
|
129
|
+
|
|
130
|
+
print("Data found:", row)
|
|
131
|
+
return row
|
|
132
|
+
|
|
133
|
+
print("No data found.")
|
|
134
|
+
if external_control is not None:
|
|
135
|
+
external_control.append(False)
|
|
136
|
+
return None
|
|
137
|
+
|
|
138
|
+
except mysql.connector.Error as e:
|
|
139
|
+
print("Get Error:", e)
|
|
140
|
+
if external_control is not None:
|
|
141
|
+
external_control.append(False)
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
# ------------------------------------------------------
|
|
145
|
+
# GET ALL
|
|
146
|
+
# ------------------------------------------------------
|
|
147
|
+
def get_all(self, table, Control=None):
|
|
148
|
+
sql = f"SELECT * FROM {table}"
|
|
149
|
+
|
|
150
|
+
try:
|
|
151
|
+
self.cursor.execute(sql)
|
|
152
|
+
rows = self.cursor.fetchall()
|
|
153
|
+
if Control is not None:
|
|
154
|
+
Control.append(True)
|
|
155
|
+
return rows
|
|
156
|
+
except mysql.connector.Error as e:
|
|
157
|
+
print("Get All Error:", e)
|
|
158
|
+
if Control is not None:
|
|
159
|
+
Control.append(False)
|
|
160
|
+
return []
|
|
161
|
+
|
|
162
|
+
# ------------------------------------------------------
|
|
163
|
+
# CONTROLL
|
|
164
|
+
# db.Controll("Users", ID=3, name="Ali", Control=durum)
|
|
165
|
+
# ------------------------------------------------------
|
|
166
|
+
def Controll(self, table, **kwargs):
|
|
167
|
+
external_control = None
|
|
168
|
+
|
|
169
|
+
if "Control" in kwargs:
|
|
170
|
+
external_control = kwargs["Control"]
|
|
171
|
+
kwargs.pop("Control")
|
|
172
|
+
|
|
173
|
+
filters = {}
|
|
174
|
+
checks = {}
|
|
175
|
+
|
|
176
|
+
for key, value in kwargs.items():
|
|
177
|
+
if key.isupper():
|
|
178
|
+
filters[key] = value
|
|
179
|
+
else:
|
|
180
|
+
checks[key] = value
|
|
181
|
+
|
|
182
|
+
if not filters:
|
|
183
|
+
print("Controll Error: ID gibi bir filtre gerekli.")
|
|
184
|
+
if external_control is not None:
|
|
185
|
+
external_control.append(False)
|
|
186
|
+
return False
|
|
187
|
+
|
|
188
|
+
where_clause = " AND ".join([f"{k}=%s" for k in filters])
|
|
189
|
+
sql = f"SELECT * FROM {table} WHERE {where_clause} LIMIT 1"
|
|
190
|
+
|
|
191
|
+
try:
|
|
192
|
+
self.cursor.execute(sql, tuple(filters.values()))
|
|
193
|
+
row = self.cursor.fetchone()
|
|
194
|
+
|
|
195
|
+
if not row:
|
|
196
|
+
print("Controll: Veri yok.")
|
|
197
|
+
if external_control is not None:
|
|
198
|
+
external_control.append(False)
|
|
199
|
+
return False
|
|
200
|
+
|
|
201
|
+
for key, expected in checks.items():
|
|
202
|
+
if key not in row or row[key] != expected:
|
|
203
|
+
print("Controll: Uyuşmayan değer:", key)
|
|
204
|
+
if external_control is not None:
|
|
205
|
+
external_control.append(False)
|
|
206
|
+
return False
|
|
207
|
+
|
|
208
|
+
print("Controll: Doğru.")
|
|
209
|
+
if external_control is not None:
|
|
210
|
+
external_control.append(True)
|
|
211
|
+
return True
|
|
212
|
+
|
|
213
|
+
except mysql.connector.Error as e:
|
|
214
|
+
print("Controll Error:", e)
|
|
215
|
+
if external_control is not None:
|
|
216
|
+
external_control.append(False)
|
|
217
|
+
return False
|
|
218
|
+
|
|
219
|
+
# ------------------------------------------------------
|
|
220
|
+
# ID_CONTROL
|
|
221
|
+
# db.ID_Control("Users", name="Ali", ID=bura, Control=durum)
|
|
222
|
+
# ------------------------------------------------------
|
|
223
|
+
def ID_Control(self, table, **kwargs):
|
|
224
|
+
external_id_var = None
|
|
225
|
+
external_control = None
|
|
226
|
+
|
|
227
|
+
if "ID" in kwargs:
|
|
228
|
+
external_id_var = kwargs["ID"]
|
|
229
|
+
kwargs.pop("ID")
|
|
230
|
+
|
|
231
|
+
if "Control" in kwargs:
|
|
232
|
+
external_control = kwargs["Control"]
|
|
233
|
+
kwargs.pop("Control")
|
|
234
|
+
|
|
235
|
+
filters = kwargs
|
|
236
|
+
|
|
237
|
+
if not filters:
|
|
238
|
+
print("ID_Control Error: name gibi filtre gerekli.")
|
|
239
|
+
if external_control is not None:
|
|
240
|
+
external_control.append(False)
|
|
241
|
+
return False
|
|
242
|
+
|
|
243
|
+
where_clause = " AND ".join([f"{k}=%s" for k in filters])
|
|
244
|
+
sql = f"SELECT ID FROM {table} WHERE {where_clause} LIMIT 1"
|
|
245
|
+
|
|
246
|
+
try:
|
|
247
|
+
self.cursor.execute(sql, tuple(filters.values()))
|
|
248
|
+
row = self.cursor.fetchone()
|
|
249
|
+
|
|
250
|
+
if not row:
|
|
251
|
+
print("ID_Control: Veri yok.")
|
|
252
|
+
if external_control is not None:
|
|
253
|
+
external_control.append(False)
|
|
254
|
+
return False
|
|
255
|
+
|
|
256
|
+
if external_id_var is not None:
|
|
257
|
+
external_id_var.clear()
|
|
258
|
+
external_id_var["ID"] = row["ID"]
|
|
259
|
+
|
|
260
|
+
print("ID_Control: ID bulundu:", row["ID"])
|
|
261
|
+
|
|
262
|
+
if external_control is not None:
|
|
263
|
+
external_control.append(True)
|
|
264
|
+
|
|
265
|
+
return row["ID"]
|
|
266
|
+
|
|
267
|
+
except mysql.connector.Error as e:
|
|
268
|
+
print("ID_Control Error:", e)
|
|
269
|
+
if external_control is not None:
|
|
270
|
+
external_control.append(False)
|
|
271
|
+
return False
|
|
@@ -1,116 +0,0 @@
|
|
|
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 []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|