1
1
import string
2
- from kivy .app import App
3
- from kivy .lang import Builder
4
- from kivy .uix .screenmanager import ScreenManager , Screen
2
+ # from kivy.app import App
3
+ # from kivy.lang import Builder
4
+ # from kivy.uix.screenmanager import ScreenManager, Screen
5
5
6
6
# ---------------------
7
7
# database handling
8
8
# ---------------------
9
9
import sqlite3
10
10
# source tutorial: https://www.youtube.com/watch?v=byHcYRpMgI4
11
- def db_init (db_name = 'profile.db' , table_name = "users" ):
11
+ def init (db_name = 'profile.db' , table_name = "users" ):
12
12
# connect to database
13
13
# database file is created if it doesn't exist
14
14
conn = sqlite3 .connect (db_name )
@@ -36,7 +36,7 @@ def db_init(db_name = 'profile.db', table_name = "users"):
36
36
37
37
return
38
38
39
- def db_un_exists (un , db_name = 'profile.db' ):
39
+ def un_exists (un , db_name = 'profile.db' ):
40
40
conn = sqlite3 .connect (db_name )
41
41
c = conn .cursor ()
42
42
c .execute (f"""SELECT un
@@ -47,13 +47,13 @@ def db_un_exists(un, db_name = 'profile.db'):
47
47
48
48
result = True if len (un_result ) else False
49
49
50
- print (f'db_un_exists ("{ un } ") result = "{ result } "' )
50
+ print (f'db.un_exists ("{ un } ") result = "{ result } "' )
51
51
52
52
conn .close ()
53
53
54
54
return result
55
55
56
- def db_profile_new (
56
+ def profile_new (
57
57
un ,
58
58
pw ,
59
59
fn ,
@@ -65,7 +65,7 @@ def db_profile_new(
65
65
conn = sqlite3 .connect (db_name )
66
66
c = conn .cursor ()
67
67
68
- if not db_un_exists (un ):
68
+ if not un_exists (un ):
69
69
c .execute (f"""INSERT INTO users VALUES (
70
70
'{ un } ',
71
71
'{ pw } ',
@@ -87,7 +87,7 @@ def db_profile_new(
87
87
88
88
return
89
89
90
- def db_profile_print (* args , ** kwargs ):
90
+ def profile_print (* args , ** kwargs ):
91
91
uns = []
92
92
print_all = False
93
93
profiles = []
@@ -134,15 +134,15 @@ def db_profile_print(*args, **kwargs):
134
134
135
135
result = True if len (profiles ) else False
136
136
137
- print (f'db_profile_print ("*{ args } , **{ kwargs } ") profiles =' )
137
+ print (f'db.profile_print ("*{ args } , **{ kwargs } ") profiles =' )
138
138
for profile in profiles :
139
139
print (profile )
140
140
141
141
conn .close ()
142
142
143
143
return result
144
144
145
- def db_un_login (un , pw , db_name = 'profile.db' ):
145
+ def un_login (un , pw , db_name = 'profile.db' ):
146
146
conn = sqlite3 .connect (db_name )
147
147
c = conn .cursor ()
148
148
c .execute (f"""SELECT rowid, first_name
@@ -156,13 +156,13 @@ def db_un_login(un, pw, db_name = 'profile.db'):
156
156
157
157
result = True if len (first_name ) else False
158
158
159
- print (f'db_un_login ("{ un } ", "{ pw } ") result = "{ result } "' )
159
+ print (f'db.un_login ("{ un } ", "{ pw } ") result = "{ result } "' )
160
160
161
161
conn .close ()
162
162
163
163
return result
164
164
165
- def db_profile_update (un , ** kwargs ):
165
+ def profile_update (un , ** kwargs ):
166
166
# handle default kwargs
167
167
if 'db_name' not in kwargs .keys ():
168
168
db_name = 'profile.db'
@@ -179,14 +179,14 @@ def db_profile_update(un, **kwargs):
179
179
WHERE un = '{ un } '
180
180
""" )
181
181
182
- print (f'db_profile_update ({ un } , { kwargs } ) executed.' )
182
+ print (f'db.profile_update ({ un } , { kwargs } ) executed.' )
183
183
184
184
conn .commit ()
185
185
conn .close ()
186
186
187
187
return
188
188
189
- def db_profile_delete (un , ** kwargs ):
189
+ def profile_delete (un , ** kwargs ):
190
190
# handle default kwargs
191
191
if 'db_name' not in kwargs .keys ():
192
192
db_name = 'profile.db'
@@ -202,78 +202,46 @@ def db_profile_delete(un, **kwargs):
202
202
WHERE un = '{ un } '
203
203
""" )
204
204
205
- print (f'db_profile_delete ({ un } ) profile deleted, if it existed in the first place.' )
205
+ print (f'db.profile_delete ({ un } ) profile deleted, if it existed in the first place.' )
206
206
207
207
conn .commit ()
208
208
conn .close ()
209
209
210
210
return
211
211
212
212
# ----------------------
213
- # Kivy Window management
213
+ # Main application function
214
214
# ----------------------
215
- class SplashWindow (Screen ):
216
- pass
217
-
218
- class LoginWindow (Screen ):
219
-
220
- def login_released (self , usnm_input , passw_input ):
221
- usnm_input .text = ""
222
- passw_input .text = ""
223
-
224
- return
225
-
226
- pass
227
-
228
- class ProfileWindow (Screen ):
229
- pass
230
-
231
- class WindowManager (ScreenManager ):
232
- pass
233
-
234
- kv = Builder .load_file ("my.kv" )
215
+ def main ():
216
+ # Database initialization and tests
217
+ # init()
218
+ # un_exists('userNameThatDoesNotExist')
219
+ # profile_delete('userNameThatDoesNotExist')
220
+ # profile_delete('davidDelSol')
221
+ # profile_new(
222
+ # 'davidDelSol',
223
+ # 'encrypted?',
224
+ # 'david',
225
+ # 'aloka',
226
+ # 'test@preform.io',
227
+ # 'salsa,extended intelligence,marathon running in a full suit'
228
+ # )
229
+ # profile_new(
230
+ # 'Python733t',
231
+ # 'encrypted?',
232
+ # 'Doroteo ',
233
+ # 'Bonilla',
234
+ # 'doabonilla@yahoo.com',
235
+ # 'work,school,sleep,repeat'
236
+ # )
237
+ # un_login('davidDelSol', 'encrypted?')
238
+ # profile_update('davidDelSol', pw = 'definitelyNotEncripted!')
239
+ # un_login('davidDelSol', 'definitelyNotEncripted!')
240
+ # un_exists('davidDelSol')
241
+ # profile_print(all = True)
242
+ # profile_print(['Python733t'])
243
+ # profile_print('Python733t')
235
244
236
- # ----------------------
237
- # Main Kivy app
238
- # ----------------------
239
- class MyMainApp (App ):
240
- def build (self ):
241
- return kv
242
245
pass
243
246
244
-
245
- # ----------------------
246
- # Main application function
247
- # ----------------------
248
- if __name__ == "__main__" :
249
- # Database initialization and tests
250
- db_init ()
251
- db_un_exists ('userNameThatDoesNotExist' )
252
- db_profile_delete ('userNameThatDoesNotExist' )
253
- db_profile_delete ('davidDelSol' )
254
- db_profile_new (
255
- 'davidDelSol' ,
256
- 'encrypted?' ,
257
- 'david' ,
258
- 'aloka' ,
259
- 'test@preform.io' ,
260
- 'salsa,extended intelligence,marathon running in a full suit'
261
- )
262
- db_profile_new (
263
- 'Python733t' ,
264
- 'encrypted?' ,
265
- 'Doroteo ' ,
266
- 'Bonilla' ,
267
- 'doabonilla@yahoo.com' ,
268
- 'work,school,sleep,repeat'
269
- )
270
- db_un_login ('davidDelSol' , 'encrypted?' )
271
- db_profile_update ('davidDelSol' , pw = 'definitelyNotEncripted!' )
272
- db_un_login ('davidDelSol' , 'definitelyNotEncripted!' )
273
- db_un_exists ('davidDelSol' )
274
- db_profile_print (all = True )
275
- db_profile_print (['Python733t' ])
276
- db_profile_print ('Python733t' )
277
-
278
- # Run Kivy app
279
- MyMainApp ().run ()
247
+ main ()
0 commit comments