-
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
1 parent
b7540b3
commit 4db5782
Showing
5 changed files
with
15 additions
and
19 deletions.
There are no files selected for viewing
Binary file not shown.
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,20 +1,13 @@ | ||
import sqlite3 | ||
def db_setup(): | ||
connection = sqlite3.connect('database.db') | ||
|
||
connection = sqlite3.connect('database.db') | ||
|
||
with open('schema.sql') as f: | ||
connection.executescript(f.read()) | ||
|
||
with open('schema.sql') as f: | ||
connection.executescript(f.read()) | ||
cur = connection.cursor() | ||
|
||
cur = connection.cursor() | ||
|
||
cur.execute("INSERT INTO posts (username, reason) VALUES (?, ?)", | ||
('First Post', 'Content for the first post') | ||
) | ||
|
||
cur.execute("INSERT INTO posts (username, reason) VALUES (?, ?)", | ||
('Second Post', 'Content for the second post') | ||
) | ||
|
||
connection.commit() | ||
connection.close() | ||
connection.commit() | ||
connection.close() |
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
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from main import app | ||
from init_db import db_setup | ||
if __name__ == "__main__": | ||
db_setup() | ||
app.run() |