forked from canonical/charmcraft
-
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.
update files for Flask tutorial spread test
- Loading branch information
Showing
4 changed files
with
68 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
config: | ||
options: | ||
greeting: | ||
description: | | ||
The greeting to be returned by the Flask application. | ||
default: "Hello, world!" | ||
type: string |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
requires: | ||
postgresql: | ||
interface: postgresql_client | ||
optional: false |
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,21 @@ | ||
import os | ||
|
||
import psycopg2 | ||
|
||
|
||
DATABASE_URI = os.environ["POSTGRESQL_DB_CONNECT_STRING"] | ||
|
||
|
||
def migrate(): | ||
with psycopg2.connect(DATABASE_URI) as conn, conn.cursor() as cur: | ||
cur.execute(""" | ||
CREATE TABLE IF NOT EXISTS visitors ( | ||
timestamp TIMESTAMP NOT NULL, | ||
user_agent TEXT NOT NULL | ||
); | ||
""") | ||
conn.commit() | ||
|
||
|
||
if __name__ == "__main__": | ||
migrate() |