-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import sqlite3 | ||
|
||
|
||
def create_sqlite_connection(): | ||
conn = sqlite3.connect('db.sqlite3') | ||
cursor = conn.cursor() | ||
return cursor | ||
|
||
|
||
db = create_sqlite_connection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import os | ||
import sqlite3 | ||
|
||
|
||
def migrate_DB(): | ||
filenames = next(os.walk("migrations/"))[2] | ||
for file in filenames: | ||
with open(f'migrations/{file}','r') as file: | ||
with open(f'migrations/{file}', 'r') as file: | ||
query = file.read() | ||
try: | ||
with sqlite3.connect('db.sqlite3') as con: | ||
con.execute(query) | ||
|
||
# TODO: make this sqlite3.Error type later | ||
except: | ||
print("Some thing is worng with the migration query?") | ||
except sqlite3.Error as err: | ||
print(f"Some thing is worng with the migration query?\nError -> {err}") |
Oops, something went wrong.