]>
Softwares of Agnibho - librevax.git/blob - librevax.py
2 # Copyright (C) 2024 Dr. Agnibho Mondal
3 # This file is part of LibreVax.
4 # LibreVax is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5 # LibreVax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6 # You should have received a copy of the GNU General Public License along with LibreVax. If not, see <https://www.gnu.org/licenses/>.
8 from flask
import Flask
, render_template
, request
, session
, redirect
, g
9 from urllib
. parse
import urlencode
10 from datetime
import datetime
12 import advice
, auth
, inventory
, multicenter
, patient
, personnel
, transaction
, vaccination
15 app
. config
. from_file ( "config/config.json" , load
= json
. load
)
19 g
. user
= session
. get ( "user" , None )
20 g
. mid
= session
. get ( "mid" , None )
21 g
. center
= session
. get ( "center" , None )
22 g
. enable_delete
= app
. config
. get ( "ENABLE_DELETE" , False )
27 if (( ret
:= problem ())!= "go" ):
29 cursor
= get_db (). cursor ()
30 ( ok
, mc
)= multicenter
. read ( cursor
, session
[ "mid" ])
33 ( ok
, pat
)= patient
. list ( cursor
)
36 return render_template ( "index.html" , center
= mc
, patient
= pat
)
37 except Exception as e
:
39 return render_template ( "error.html" , data
= e
)
42 def login_get ( error
= False ):
44 cursor
= get_db (). cursor ()
45 ( ok
, data
)= multicenter
. list ( cursor
)
50 return render_template ( "login.html" , data
= data
, error
= error
)
51 except Exception as e
:
52 return render_template ( "error.html" , data
= e
)
56 cursor
= get_db (). cursor ()
57 if ( auth
. login ( cursor
, request
. form
[ "user" ], request
. form
[ "password" ], request
. form
[ "center" ])):
60 return login_get ( True )
65 return redirect ( "/login" )
69 cursor
= get_db (). cursor ()
70 ( ok
, mc
)= multicenter
. list ( cursor
)
73 users
= auth
. list ( cursor
)
74 return render_template ( "admin.html" , users
= users
, center
= mc
, msg
= msg
)
79 cursor
= get_db (). cursor ()
80 if ( auth
. new ( cursor
, request
. form
[ "user" ], request
. form
[ "pwd" ])):
81 return admin ( msg
= "New user added" )
83 return admin ( msg
= "Failed to add" )
84 except Exception as e
:
86 return render_template ( "error.html" , data
= e
)
88 @app . post ( "/changepass" )
91 cursor
= get_db (). cursor ()
92 if ( "user" in request
. form
. keys ()):
93 if ( auth
. change ( cursor
, request
. form
[ "user" ], request
. form
[ "new" ])):
94 return admin ( msg
= "Password changed" )
96 return admin ( msg
= "Incorrect Password" )
97 elif ( request
. form
[ "new" ]== request
. form
[ "check" ]):
98 user
= request
. form
. get ( "user" , session
[ "user" ])
99 if ( auth
. change ( cursor
, user
, request
. form
[ "new" ], request
. form
[ "old" ])):
100 return admin ( msg
= "Password changed" )
102 return admin ( msg
= "Incorrect Password" )
104 return admin ( msg
= "Failed to change password" )
105 except Exception as e
:
107 return render_template ( "error.html" , data
= e
)
109 @app . post ( "/switchcenter" )
112 cursor
= get_db (). cursor ()
113 if ( auth
. switch ( cursor
, request
. form
)):
114 return admin ( msg
= "Switched center to " + g
. center
)
116 raise Exception ( "Failed to switch" )
117 except Exception as e
:
119 return render_template ( "error.html" , data
= e
)
121 @app . get ( "/center/<action>" )
122 @app . get ( "/center/<action>/<mid>" )
123 def center_view ( action
, mid
= None ):
124 if (( ret
:= problem ())!= "go" ):
127 cursor
= get_db (). cursor ()
129 ( ok
, data
)= multicenter
. list ( cursor
)
131 raise exception ( data
)
132 return render_template ( "multicenter-view.html" , data
= data
, action
= action
)
133 elif ( action
== "view" ):
135 ( ok
, data
)= multicenter
. read ( cursor
, mid
)
137 raise Exception ( data
)
138 ( ok
, invt
)= inventory
. list ( cursor
, mid
)
140 raise Exception ( invt
)
141 ( ok
, pers
)= personnel
. list ( cursor
, mid
)
143 raise Exception ( pers
)
144 return render_template ( "multicenter-view.html" , data
= data
, inventory
= invt
, personnel
= pers
, action
= action
)
146 raise Exception ( "Invalid parameter" )
147 elif ( action
== "edit" ):
149 ( ok
, data
)= multicenter
. read ( cursor
, mid
)
151 raise Exception ( data
)
152 return render_template ( "multicenter-edit.html" , data
= data
, action
= action
)
154 raise Exception ( "Invalid parameter" )
156 return render_template ( "multicenter-edit.html" , data
=[], action
= action
)
157 except Exception as e
:
159 return render_template ( "error.html" , data
= e
)
161 @app . get ( "/personnel/<action>" )
162 @app . get ( "/personnel/<action>/<sid>" )
163 def personnel_view ( action
, sid
= None ):
164 if (( ret
:= problem ())!= "go" ):
167 cursor
= get_db (). cursor ()
169 ( ok
, data
)= personnel
. list ( cursor
, g
. mid
)
171 raise exception ( data
)
172 return render_template ( "personnel-view.html" , data
= data
, action
= action
)
173 elif ( action
== "view" ):
175 ( ok
, data
)= personnel
. read ( cursor
, sid
)
177 raise Exception ( data
)
178 return render_template ( "personnel-view.html" , data
= data
, action
= action
)
180 raise Exception ( "Invalid parameter" )
181 elif ( action
== "edit" ):
183 ( ok
, data
)= personnel
. read ( cursor
, sid
)
185 raise Exception ( data
)
186 ( ok
, center
)= multicenter
. list ( cursor
)
188 raise Exception ( center
)
189 return render_template ( "personnel-edit.html" , data
= data
, center
= center
, action
= action
)
191 raise Exception ( "Invalid parameter" )
193 ( ok
, center
)= multicenter
. list ( cursor
)
195 raise Exception ( center
)
196 return render_template ( "personnel-edit.html" , data
=[], center
= center
, action
= action
)
197 except Exception as e
:
199 return render_template ( "error.html" , data
= e
)
201 @app . post ( "/personnel/new" )
202 @app . post ( "/personnel/edit/<sid>" )
203 def personnel_edit ( sid
= None ):
204 if (( ret
:= problem ())!= "go" ):
207 cursor
= get_db (). cursor ()
209 active
= "active" in request
. form
. keys ()
210 ( ok
, data
)= personnel
. create ( cursor
, request
. form
, active
)
212 raise Exception ( data
)
215 active
= "active" in request
. form
. keys ()
216 ( ok
, data
)= personnel
. update ( cursor
, sid
, request
. form
, active
)
218 raise Exception ( data
)
219 return redirect ( "/personnel/view/" + str ( sid
))
220 except Exception as e
:
221 return render_template ( "error.html" , data
= e
)
223 @app . post ( "/center/new" )
224 @app . post ( "/center/edit/<mid>" )
225 def center_edit ( mid
= None ):
226 if (( ret
:= problem ())!= "go" ):
229 cursor
= get_db (). cursor ()
231 ( ok
, data
)= multicenter
. create ( cursor
, request
. form
)
233 raise Exception ( data
)
236 ( ok
, data
)= multicenter
. update ( cursor
, mid
, request
. form
)
238 raise Exception ( data
)
239 return redirect ( "/center/view/" + str ( mid
))
240 except Exception as e
:
241 return render_template ( "error.html" , data
= e
)
243 @app . get ( "/inventory/<action>" )
244 @app . get ( "/inventory/<action>/<id>" )
245 def inventory_view ( action
, id = None ):
246 if (( ret
:= problem ())!= "go" ):
249 cursor
= get_db (). cursor ()
252 ( ok
, data
)= inventory
. list ( cursor
, id , all
= True )
254 raise exception ( data
)
255 ( ok
, center
)= multicenter
. read ( cursor
, id )
257 raise exception ( center
)
258 return render_template ( "inventory-view.html" , data
= data
, center
= center
, action
= action
)
260 raise Exception ( "Invalid parameter" )
261 elif ( action
== "view" ):
263 ( ok
, data
)= inventory
. read ( cursor
, id )
265 raise Exception ( data
)
266 return render_template ( "inventory-view.html" , data
= data
, action
= action
)
268 raise Exception ( "Invalid parameter" )
269 elif ( action
== "edit" ):
271 ( ok
, data
)= inventory
. read ( cursor
, id )
273 raise Exception ( data
)
274 return render_template ( "inventory-edit.html" , data
= data
, mid
= data
[ "mid" ], action
= action
)
276 raise Exception ( "Invalid parameter" )
279 ( ok
, center
)= multicenter
. list ( cursor
)
281 raise Exception ( center
)
282 return render_template ( "inventory-edit.html" , data
=[], mid
= id , action
= action
, center
= center
)
284 raise Exception ( "Invalid parameter" )
285 except Exception as e
:
287 return render_template ( "error.html" , data
= e
)
289 @app . post ( "/inventory/new/<mid>" )
290 @app . post ( "/inventory/edit/<iid>" )
291 def inventory_edit ( mid
= None , iid
= None ):
292 if (( ret
:= problem ())!= "go" ):
295 cursor
= get_db (). cursor ()
297 available
= "available" in request
. form
. keys ()
298 ( ok
, data
)= inventory
. create ( cursor
, request
. form
, available
)
300 raise Exception ( data
)
303 available
= "available" in request
. form
. keys ()
304 ( ok
, data
)= inventory
. update ( cursor
, iid
, request
. form
, available
)
306 raise Exception ( data
)
307 return redirect ( "/inventory/view/" + str ( iid
))
308 except Exception as e
:
310 return render_template ( "error.html" , data
= e
)
312 @app . get ( "/patient/<action>" )
313 @app . get ( "/patient/<action>/<pid>" )
314 def patient_view ( action
, pid
= None ):
315 if (( ret
:= problem ())!= "go" ):
318 cursor
= get_db (). cursor ()
321 page
= int ( request
. args
[ "page" ])
324 if ( request
. args
. get ( "all" , False )):
325 ( ok
, data
)= patient
. list ( cursor
, request
. args
, g
. mid
)
327 ( ok
, data
)= patient
. list ( cursor
, request
. args
)
329 param
= dict ( request
. args
)
330 param
. pop ( "page" , None )
331 return render_template ( "patient-list.html" , num
= app
. config
[ "LIST_LENGTH" ], data
= data
, page
= page
, args
= request
. args
, param
= urlencode ( param
))
333 raise Exception ( data
)
334 elif ( action
== "view" ):
336 ( ok
, data
)= patient
. read ( cursor
, pid
)
338 raise Exception ( data
)
339 ( ok
, vac
)= vaccination
. list_by_patient ( cursor
, pid
)
342 ( ok
, adv
)= advice
. list ( cursor
, pid
)
346 return render_template ( "patient-view.html" , data
= data
, vaccination
= vac
, advice
= adv
, action
= action
)
348 raise Exception ( "Invalid parameter" )
349 elif ( action
== "edit" ):
351 ( ok
, data
)= patient
. read ( cursor
, pid
)
353 raise Exception ( data
)
354 ( ok
, center
)= multicenter
. list ( cursor
)
356 raise exception ( center
)
357 return render_template ( "patient-edit.html" , data
= data
, center
= center
, action
= action
)
359 raise Exception ( "Invalid parameter" )
361 ( ok
, last
)= patient
. last ( cursor
)
363 raise Exception ( last
)
364 data
={ "lastCid" : last
[ "cid" ]}
365 ( ok
, center
)= multicenter
. list ( cursor
)
367 raise exception ( center
)
368 return render_template ( "patient-edit.html" , data
= data
, center
= center
, action
= action
)
369 except Exception as e
:
371 return render_template ( "error.html" , data
= e
)
373 @app . post ( "/patient/new" )
374 @app . post ( "/patient/edit/<pid>" )
375 def patient_edit ( pid
= None ):
376 if (( ret
:= problem ())!= "go" ):
379 cursor
= get_db (). cursor ()
381 ( ok
, data
)= patient
. create ( cursor
, request
. form
)
383 if ( isinstance ( data
, sqlite3
. IntegrityError
)):
385 ( ok
, center
)= multicenter
. list ( cursor
)
387 raise exception ( center
)
388 ( ok
, last
)= patient
. last ( cursor
)
390 raise Exception ( last
)
391 data
. lastCid
= last
[ "cid" ]
392 return render_template ( "patient-edit.html" , data
= data
, center
= center
, action
= "uniq" )
394 raise Exception ( data
)
397 ( ok
, data
)= patient
. update ( cursor
, pid
, request
. form
)
399 raise Exception ( data
)
400 return redirect ( "/patient/view/" + str ( pid
))
401 except Exception as e
:
402 return render_template ( "error.html" , data
= e
)
404 @app . get ( "/note/<pid>" )
406 if (( ret
:= problem ())!= "go" ):
409 cursor
= get_db (). cursor ()
410 ( ok
, data
)= patient
. read ( cursor
, pid
)
412 return render_template ( "note.html" , data
= data
)
414 return render_template ( "error.html" , data
= data
)
415 except Exception as e
:
417 return render_template ( "error.html" , data
= e
)
419 @app . post ( "/note/<pid>" )
421 if (( ret
:= problem ())!= "go" ):
424 cursor
= get_db (). cursor ()
425 ( ok
, data
)= patient
. note ( cursor
, pid
, request
. form
)
427 return render_template ( "error.html" , data
= data
)
428 return redirect ( "/patient/view/" + str ( pid
))
429 except Exception as e
:
431 return render_template ( "error.html" , data
= e
)
433 @app . get ( "/vaccination/<action>" )
434 @app . get ( "/vaccination/<action>/<id>" )
435 def vaccination_view ( action
, id = None ):
436 if (( ret
:= problem ())!= "go" ):
439 cursor
= get_db (). cursor ()
442 ( ok
, data
)= vaccination
. list_by_patient ( cursor
, id )
444 raise exception ( data
)
445 ( ok
, pat
)= patient
. read ( cursor
, data
[ "pid" ])
447 raise exception ( patient
)
448 ( ok
, inv
)= inventory
. list ( cursor
, data
[ "iid" ])
450 raise exception ( inventory
)
451 return render_template ( "vaccination-view.html" , data
= data
, patient
= pat
, inventory
= inv
, action
= action
)
453 raise Exception ( "Invalid parameter" )
454 elif ( action
== "view" ):
456 ( ok
, data
)= vaccination
. read ( cursor
, id )
458 raise Exception ( data
)
459 ( ok
, inv
)= inventory
. read ( cursor
, data
[ "iid" ])
462 ( ok
, pat
)= patient
. read ( cursor
, data
[ "pid" ])
465 ( ok
, consultant
)= personnel
. read ( cursor
, data
[ "consultant" ])
467 raise Exception ( consultant
)
468 ( ok
, vaccinator
)= personnel
. read ( cursor
, data
[ "vaccinator" ])
470 raise Exception ( vaccinator
)
471 return render_template ( "vaccination-view.html" , data
= data
, inventory
= inv
, patient
= pat
, consultant
= consultant
, vaccinator
= vaccinator
, action
= action
)
473 raise Exception ( "Invalid parameter" )
474 elif ( action
== "edit" ):
476 ( ok
, data
)= vaccination
. read ( cursor
, id )
478 raise Exception ( data
)
479 ( ok
, inv
)= inventory
. list ( cursor
, g
. mid
)
482 ( ok
, consultant
)= personnel
. list ( cursor
, g
. mid
, "consultant" )
484 raise Exception ( consultant
)
485 ( ok
, vaccinator
)= personnel
. list ( cursor
, g
. mid
, "vaccinator" )
487 raise Exception ( vaccinator
)
488 ( ok
, pat
)= patient
. read ( cursor
, data
[ "pid" ])
491 return render_template ( "vaccination-edit.html" , data
= data
, inventory
= inv
, consultant
= consultant
, vaccinator
= vaccinator
, patient
= pat
, action
= action
)
493 raise Exception ( "Invalid parameter" )
496 ( ok
, inv
)= inventory
. list ( cursor
, g
. mid
)
499 ( ok
, consultant
)= personnel
. list ( cursor
, g
. mid
, "consultant" )
501 raise Exception ( consultant
)
502 ( ok
, vaccinator
)= personnel
. list ( cursor
, g
. mid
, "vaccinator" )
504 raise Exception ( vaccinator
)
505 ( ok
, pat
)= patient
. read ( cursor
, id )
508 data
={ "pid" : id , "date" : datetime
. now (). strftime ( "%Y-%m- %d T%H:%M:%S" )}
510 raise Exception ( "Please add a vaccine to inventory before vaccination." )
511 return render_template ( "vaccination-edit.html" , data
= data
, inventory
= inv
, consultant
= consultant
, vaccinator
= vaccinator
, patient
= pat
, action
= action
)
513 raise Exception ( "Invalid parameter" )
514 except Exception as e
:
515 return render_template ( "error.html" , data
= e
)
517 @app . post ( "/vaccination/new/<pid>" )
518 @app . post ( "/vaccination/edit/<vid>" )
519 def vaccination_edit ( vid
= None , pid
= None ):
520 if (( ret
:= problem ())!= "go" ):
523 cursor
= get_db (). cursor ()
525 given
= "given" in request
. form
. keys ()
526 ( ok
, data
)= vaccination
. create ( cursor
, request
. form
, given
)
528 raise Exception ( data
)
531 given
= "given" in request
. form
. keys ()
532 ( ok
, data
)= vaccination
. update ( cursor
, vid
, request
. form
, given
)
534 raise Exception ( data
)
535 return redirect ( "/vaccination/view/" + str ( vid
))
536 except Exception as e
:
538 return render_template ( "error.html" , data
= e
)
541 @app . get ( "/advice/<action>" )
542 @app . get ( "/advice/<action>/<id>" )
543 def advice_view ( action
, id = None ):
544 if (( ret
:= problem ())!= "go" ):
547 cursor
= get_db (). cursor ()
550 ( ok
, data
)= advice
. list ( cursor
, id )
552 raise exception ( data
)
553 ( ok
, pat
)= patient
. read ( cursor
, id )
555 raise exception ( patient
)
556 return render_template ( "advice-view.html" , data
= data
, patient
= pat
, action
= action
)
558 raise Exception ( "Invalid parameter" )
559 elif ( action
== "view" ):
561 ( ok
, data
)= advice
. read ( cursor
, id )
563 raise Exception ( data
)
564 ( ok
, pat
)= patient
. read ( cursor
, data
[ "pid" ])
567 ( ok
, consultant
)= personnel
. read ( cursor
, data
[ "consultant" ])
569 raise Exception ( consultant
)
570 return render_template ( "advice-view.html" , data
= data
, patient
= pat
, consultant
= consultant
, action
= action
)
572 raise Exception ( "Invalid parameter" )
573 elif ( action
== "edit" ):
575 ( ok
, data
)= advice
. read ( cursor
, g
. mid
)
577 raise Exception ( data
)
578 ( ok
, consultant
)= personnel
. list ( cursor
, g
. mid
, "consultant" )
580 raise Exception ( consultant
)
581 return render_template ( "advice-edit.html" , data
= data
, consultant
= consultant
, action
= action
)
583 raise Exception ( "Invalid parameter" )
586 ( ok
, consultant
)= personnel
. list ( cursor
, g
. mid
, "consultant" )
588 raise Exception ( consultant
)
589 data
={ "pid" : id , "date" : datetime
. now (). strftime ( "%Y-%m- %d T%H:%M:%S" )}
590 return render_template ( "advice-edit.html" , data
= data
, consultant
= consultant
, action
= action
)
592 raise Exception ( "Invalid parameter" )
593 except Exception as e
:
595 return render_template ( "error.html" , data
= e
)
597 @app . post ( "/advice/new/<pid>" )
598 @app . post ( "/advice/edit/<aid>" )
599 def advice_edit ( aid
= None , pid
= None ):
600 if (( ret
:= problem ())!= "go" ):
603 cursor
= get_db (). cursor ()
605 ( ok
, data
)= advice
. create ( cursor
, request
. form
, pid
)
607 raise Exception ( data
)
610 ( ok
, data
)= advice
. update ( cursor
, aid
, request
. form
)
612 raise Exception ( data
)
613 return redirect ( "/advice/view/" + str ( aid
))
614 except Exception as e
:
616 return render_template ( "error.html" , data
= e
)
618 @app . get ( "/delete/<cat>/<id>" )
620 if (( ret
:= problem ())!= "go" ):
623 if ( not g
. enable_delete
):
624 raise Exception ( "Deleting record is not allowed." )
625 cursor
= get_db (). cursor ()
627 ( ok
, data
)= advice
. delete ( cursor
, id )
629 return render_template ( "error.html" , data
= data
)
630 elif ( cat
== "inventory" ):
631 ( ok
, data
)= inventory
. delete ( cursor
, id )
633 return render_template ( "error.html" , data
= data
)
635 ( ok
, data
)= multicenter
. delete ( cursor
, id )
637 return render_template ( "error.html" , data
= data
)
638 elif ( cat
== "patient" ):
639 ( ok
, data
)= patient
. delete ( cursor
, id )
641 return render_template ( "error.html" , data
= data
)
642 elif ( cat
== "personnel" ):
643 ( ok
, data
)= personnel
. delete ( cursor
, id )
645 return render_template ( "error.html" , data
= data
)
646 elif ( cat
== "transaction" ):
647 ( ok
, data
)= transaction
. delete ( cursor
, id )
649 return render_template ( "error.html" , data
= data
)
650 elif ( cat
== "vaccination" ):
651 ( ok
, data
)= vaccination
. delete ( cursor
, id )
653 return render_template ( "error.html" , data
= data
)
655 except Exception as e
:
657 return render_template ( "error.html" , data
= e
)
659 @app . route ( "/card/<pid>" )
661 if (( ret
:= problem ())!= "go" ):
664 cursor
= get_db (). cursor ()
665 ( ok
, data
)= patient
. read ( cursor
, pid
)
667 raise Exception ( data
)
668 ( ok
, vac
)= vaccination
. list_by_patient ( cursor
, pid
)
671 ( ok
, adv
)= advice
. list ( cursor
, pid
)
674 ( ok
, center
)= multicenter
. read ( cursor
, g
. mid
)
676 raise Exception ( center
)
677 return render_template ( "card.html" , data
= data
, vaccination
= vac
, advice
= adv
, center
= center
)
678 except Exception as e
:
680 return render_template ( "error.html" , data
= e
)
682 @app . route ( "/report/<mid>" )
684 if (( ret
:= problem ())!= "go" ):
687 date
= request
. args
. get ( "date" , datetime
. now (). strftime ( "%Y-%m- %d " ))
688 cursor
= get_db (). cursor ()
689 ( ok
, data
)= vaccination
. list_by_date ( cursor
, date
)
691 raise Exception ( data
)
692 ( ok
, center
)= multicenter
. read ( cursor
, g
. mid
)
694 raise Exception ( center
)
695 return render_template ( "report.html" , data
= data
, center
= center
, date
= date
)
696 except Exception as e
:
698 return render_template ( "error.html" , data
= e
)
702 db
= getattr ( g
, "_database" , None )
704 db
= g
._ database
= sqlite3
. connect ( "data/database.db" , isolation_level
= None )
705 db
. row_factory
= sqlite3
. Row
708 @app . teardown_appcontext
709 def close_connection ( exception
):
710 db
= getattr ( g
, "_database" , None )
714 def problem ( access
= "" ):
715 if ( auth
. access ()== auth
. auth
. ALL
):
718 return redirect ( "/login" )
720 @app . template_filter ( "format_date" )
721 def format_date ( date
):
724 dt
= datetime
. strptime ( date
, "%Y-%m- %d T%H:%M:%S" )
725 return dt
. strftime ( "%b %d , %Y, %I:%M %p" )
727 dt
= datetime
. strptime ( date
, "%Y-%m- %d " )
728 return dt
. strftime ( "%b %d , %Y" )
729 except Exception as e
:
732 @app . template_filter ( "calculate_age" )
733 def calculate_age ( dob
):
735 today
= datetime
. today ()
737 born
= datetime
. strptime ( dob
, "%Y-%m- %d " )
739 born
= datetime
. strptime ( dob
, "%Y" )
740 return today
. year
- born
. year
-(( today
. month
, today
. day
)<( born
. month
, born
. day
))
741 except Exception as e
:
745 with app
. app_context ():
747 with app
. open_resource ( "etc/schema.sql" , mode
= "r" ) as f
:
748 db
. cursor (). executescript ( f
. read ())