Qwael 4.0.4.5__tar.gz → 4.0.4.7__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: 4.0.4.5
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
@@ -0,0 +1,160 @@
1
+ from supabase import create_client
2
+ from threading import Thread
3
+ import time
4
+
5
+
6
+ class ADB:
7
+
8
+ def __init__(self, url, key):
9
+ self.db = create_client(url, key)
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()
24
+
25
+ # ================= AUTH =================
26
+
27
+ def a_kayit_ol(self, email, sifre, callback=None):
28
+ self._async(
29
+ lambda: self.db.auth.sign_up({
30
+ "email": email,
31
+ "password": sifre
32
+ }),
33
+ callback
34
+ )
35
+
36
+ def a_giris_yap(self, email, sifre, callback=None):
37
+
38
+ def islem():
39
+ res = self.db.auth.sign_in_with_password({
40
+ "email": email,
41
+ "password": sifre
42
+ })
43
+ self.current_uid = res.user.id
44
+ return self.current_uid
45
+
46
+ self._async(islem, callback)
47
+
48
+ def cikis_yap(self):
49
+ try:
50
+ self.db.auth.sign_out()
51
+ self.current_uid = None
52
+ except:
53
+ pass
54
+
55
+ # ================= VERİ TABANI =================
56
+
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
69
+
70
+ return self.db.table(tablo).insert(veriler).execute()
71
+
72
+ self._async(islem, callback)
73
+
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)\
88
+ .execute().data
89
+
90
+ self._async(islem, callback)
91
+
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)\
106
+ .execute()
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.5
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
@@ -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="4.0.4.5",
8
+ version="4.0.4.7",
9
9
  packages=find_packages(),
10
10
  install_requires=[
11
11
  "google-api-python-client",
@@ -1,88 +0,0 @@
1
- from supabase import create_client
2
- import time
3
-
4
-
5
- class ADB:
6
- def __init__(self, url, key):
7
- self.url = url
8
- self.key = key
9
- self.db = create_client(url, key)
10
- self.oturum = None # kullanıcı session
11
-
12
- # ================= AUTH =================
13
-
14
- def a_kayit_ol(self, email, sifre):
15
- try:
16
- return self.db.auth.sign_up({
17
- "email": email,
18
- "password": sifre
19
- })
20
- except Exception as e:
21
- print("Kayıt hatası:", e)
22
- return None
23
-
24
- def a_giris_yap(self, email, sifre):
25
- try:
26
- sonuc = self.db.auth.sign_in_with_password({
27
- "email": email,
28
- "password": sifre
29
- })
30
-
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
37
-
38
- # Oturum düşerse yenile
39
- def _kontrol_et(self):
40
- try:
41
- if self.oturum:
42
- self.db.auth.set_session(
43
- self.oturum.access_token,
44
- self.oturum.refresh_token
45
- )
46
- except:
47
- pass
48
-
49
- # ================= TABLO =================
50
-
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
-
58
- try:
59
- veriler["user_id"] = uid
60
- return self.db.table(tablo).insert(veriler).execute()
61
- except Exception as e:
62
- print("Veri ekleme hatası:", e)
63
- return None
64
-
65
- def get(self, tablo, uid):
66
- self._kontrol_et()
67
-
68
- try:
69
- return self.db.table(tablo) \
70
- .select("*") \
71
- .eq("user_id", uid) \
72
- .single() \
73
- .execute().data
74
- except Exception as e:
75
- print("Veri alma hatası:", e)
76
- return None
77
-
78
- def update(self, tablo, uid, **veriler):
79
- self._kontrol_et()
80
-
81
- try:
82
- return self.db.table(tablo) \
83
- .update(veriler) \
84
- .eq("user_id", uid) \
85
- .execute()
86
- except Exception as e:
87
- print("Güncelleme hatası:", e)
88
- return None
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