Qwael 4.0.4.6__py3-none-any.whl → 4.0.4.7__py3-none-any.whl

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/adbfull.py CHANGED
@@ -1,88 +1,160 @@
1
1
  from supabase import create_client
2
+ from threading import Thread
2
3
  import time
3
4
 
4
5
 
5
6
  class ADB:
7
+
6
8
  def __init__(self, url, key):
7
- self.url = url
8
- self.key = key
9
9
  self.db = create_client(url, key)
10
- self.oturum = None # kullanıcı session
10
+ self.current_uid = None
11
+
12
+ # ================= THREAD SİSTEM =================
13
+
14
+ def _async(self, func, callback=None):
15
+ def run():
16
+ try:
17
+ sonuc = func()
18
+ if callback:
19
+ callback(sonuc)
20
+ except Exception as e:
21
+ print("ADB HATA:", e)
22
+
23
+ Thread(target=run, daemon=True).start()
11
24
 
12
25
  # ================= AUTH =================
13
26
 
14
- def a_kayit_ol(self, email, sifre):
15
- try:
16
- return self.db.auth.sign_up({
27
+ def a_kayit_ol(self, email, sifre, callback=None):
28
+ self._async(
29
+ lambda: self.db.auth.sign_up({
17
30
  "email": email,
18
31
  "password": sifre
19
- })
20
- except Exception as e:
21
- print("Kayıt hatası:", e)
22
- return None
32
+ }),
33
+ callback
34
+ )
23
35
 
24
- def a_giris_yap(self, email, sifre):
25
- try:
26
- sonuc = self.db.auth.sign_in_with_password({
36
+ def a_giris_yap(self, email, sifre, callback=None):
37
+
38
+ def islem():
39
+ res = self.db.auth.sign_in_with_password({
27
40
  "email": email,
28
41
  "password": sifre
29
42
  })
43
+ self.current_uid = res.user.id
44
+ return self.current_uid
30
45
 
31
- self.oturum = sonuc.session # session sakla
32
- return sonuc.user.id # uid döndür
33
-
34
- except Exception as e:
35
- print("Giriş hatası:", e)
36
- return None
46
+ self._async(islem, callback)
37
47
 
38
- # Oturum düşerse yenile
39
- def _kontrol_et(self):
48
+ def cikis_yap(self):
40
49
  try:
41
- if self.oturum:
42
- self.db.auth.set_session(
43
- self.oturum.access_token,
44
- self.oturum.refresh_token
45
- )
50
+ self.db.auth.sign_out()
51
+ self.current_uid = None
46
52
  except:
47
53
  pass
48
54
 
49
- # ================= TABLO =================
55
+ # ================= VERİ TABANI =================
50
56
 
51
- def add(self, tablo, uid, **veriler):
52
- """
53
- Örnek:
54
- add("users_data", uid, username="Ali Kaya", skor=34)
55
- """
56
- self._kontrol_et()
57
+ def add(self, tablo, uid=None, callback=None, **veriler):
58
+
59
+ def islem():
60
+ if uid is None:
61
+ uid_kullan = self.current_uid
62
+ else:
63
+ uid_kullan = uid
64
+
65
+ if uid_kullan is None:
66
+ raise Exception("UID yok, önce giriş yap")
67
+
68
+ veriler["user_id"] = uid_kullan
57
69
 
58
- try:
59
- veriler["user_id"] = uid
60
70
  return self.db.table(tablo).insert(veriler).execute()
61
- except Exception as e:
62
- print("Veri ekleme hatası:", e)
63
- return None
64
71
 
65
- def get(self, tablo, uid):
66
- self._kontrol_et()
72
+ self._async(islem, callback)
67
73
 
68
- try:
69
- return self.db.table(tablo) \
70
- .select("*") \
71
- .eq("user_id", uid) \
72
- .single() \
74
+ def get(self, tablo, uid=None, callback=None):
75
+
76
+ def islem():
77
+ if uid is None:
78
+ uid_kullan = self.current_uid
79
+ else:
80
+ uid_kullan = uid
81
+
82
+ if uid_kullan is None:
83
+ raise Exception("UID yok")
84
+
85
+ return self.db.table(tablo)\
86
+ .select("*")\
87
+ .eq("user_id", uid_kullan)\
73
88
  .execute().data
74
- except Exception as e:
75
- print("Veri alma hatası:", e)
76
- return None
77
89
 
78
- def update(self, tablo, uid, **veriler):
79
- self._kontrol_et()
90
+ self._async(islem, callback)
80
91
 
81
- try:
82
- return self.db.table(tablo) \
83
- .update(veriler) \
84
- .eq("user_id", uid) \
92
+ def update(self, tablo, uid=None, callback=None, **veriler):
93
+
94
+ def islem():
95
+ if uid is None:
96
+ uid_kullan = self.current_uid
97
+ else:
98
+ uid_kullan = uid
99
+
100
+ if uid_kullan is None:
101
+ raise Exception("UID yok")
102
+
103
+ return self.db.table(tablo)\
104
+ .update(veriler)\
105
+ .eq("user_id", uid_kullan)\
85
106
  .execute()
86
- except Exception as e:
87
- print("Güncelleme hatası:", e)
88
- return None
107
+
108
+ self._async(islem, callback)
109
+
110
+ def delete(self, tablo, uid=None, callback=None):
111
+
112
+ def islem():
113
+ if uid is None:
114
+ uid_kullan = self.current_uid
115
+ else:
116
+ uid_kullan = uid
117
+
118
+ if uid_kullan is None:
119
+ raise Exception("UID yok")
120
+
121
+ return self.db.table(tablo)\
122
+ .delete()\
123
+ .eq("user_id", uid_kullan)\
124
+ .execute()
125
+
126
+ self._async(islem, callback)
127
+
128
+
129
+ # ================= KULLANIMI DAHA BASİT OLSUN DİYE =================
130
+
131
+ _db = None
132
+
133
+
134
+ def baslat(url, key):
135
+ global _db
136
+ _db = ADB(url, key)
137
+
138
+
139
+ def a_kayit_ol(email, sifre, callback=None):
140
+ _db.a_kayit_ol(email, sifre, callback)
141
+
142
+
143
+ def a_giris_yap(email, sifre, callback=None):
144
+ _db.a_giris_yap(email, sifre, callback)
145
+
146
+
147
+ def add(tablo, uid=None, callback=None, **veriler):
148
+ _db.add(tablo, uid, callback, **veriler)
149
+
150
+
151
+ def get(tablo, uid=None, callback=None):
152
+ _db.get(tablo, uid, callback)
153
+
154
+
155
+ def update(tablo, uid=None, callback=None, **veriler):
156
+ _db.update(tablo, uid, callback, **veriler)
157
+
158
+
159
+ def delete(tablo, uid=None, callback=None):
160
+ _db.delete(tablo, uid, callback)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Qwael
3
- Version: 4.0.4.6
3
+ Version: 4.0.4.7
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,11 +4,11 @@ Qwael/EasyWeb.py,sha256=78XBEIuHjUm0j-TOPsN0sy0iXl8UywKAi0dNn-evWSY,1283
4
4
  Qwael/MultiDB.py,sha256=glptDsH22TyklZrA_ywStnsT6bGnq7JsSR5NN_U1NII,17286
5
5
  Qwael/Multidata.py,sha256=YBofvzcuT-F8RIljw3Z1tr3Qn7VbhXjfrY6BuGNPYw0,9496
6
6
  Qwael/__init__.py,sha256=80N86isqJ_EhDy0-wlUe6BFO1CpJvb61wYgt14b4bEM,230
7
- Qwael/adbfull.py,sha256=2OFxvTUa2p9QWrBNniPzHtJsdHy2q0a-jPYGnWLqg7s,2349
7
+ Qwael/adbfull.py,sha256=wNn5mQI5CBDpkVu_XTvSmtJrZ2nouxx7D4RcWNG4-ls,3918
8
8
  Qwael/filesz.py,sha256=6XZ1GKzXcVs7uKAirImbBuZYGrRL_-WOtiOOYOdp_nU,2501
9
9
  Qwael/pgif.py,sha256=stiVsn1DAJyHNsAHUWaWXdGiouQ2ZeRehn_WC30SK1A,1242
10
- qwael-4.0.4.6.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- qwael-4.0.4.6.dist-info/METADATA,sha256=iQLYOQMQxY4uT-_Wa9czCTIA4Cxx7NiDNTbq-ggR5kk,2399
12
- qwael-4.0.4.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
- qwael-4.0.4.6.dist-info/top_level.txt,sha256=UtaXY8Mui4lwYNkGrplHcEVe8PjH553OT1Xu5V9bhg0,6
14
- qwael-4.0.4.6.dist-info/RECORD,,
10
+ qwael-4.0.4.7.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ qwael-4.0.4.7.dist-info/METADATA,sha256=lBQtc7BfzKCrIyKqQo49x74v6DzOHlvC3SiGEP46_UM,2399
12
+ qwael-4.0.4.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ qwael-4.0.4.7.dist-info/top_level.txt,sha256=UtaXY8Mui4lwYNkGrplHcEVe8PjH553OT1Xu5V9bhg0,6
14
+ qwael-4.0.4.7.dist-info/RECORD,,