Skip to content

Commit

Permalink
create gloable sqlite conn
Browse files Browse the repository at this point in the history
  • Loading branch information
deepattic committed Nov 23, 2024
1 parent 399fde5 commit c05d08d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libwardenpy/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sqlite3
from contextlib import contextmanager


### This just create a sqlite connection to pass around the other functions
### https://stackoverflow.com/questions/67436362/decorator-for-sqlite3/67436763#67436763
@contextmanager
def get_connection(DB_PATH="data/db.sqlite3"):
conn = sqlite3.connect(DB_PATH)
try:
yield conn
finally:
conn.close()

0 comments on commit c05d08d

Please sign in to comment.