-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add package type hints * Add helper script to create schema
- Loading branch information
1 parent
c2b4e32
commit e6d9832
Showing
3 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,17 @@ | ||
import os | ||
|
||
from datastore.shared.di import injector | ||
from datastore.shared.postgresql_backend import ConnectionHandler | ||
|
||
|
||
def create_schema() -> None: | ||
""" | ||
Helper function to write the database schema into the database. | ||
""" | ||
connection_handler = injector.get(ConnectionHandler) | ||
with connection_handler.get_connection_context(): | ||
with connection_handler.get_current_connection().cursor() as cursor: | ||
path = os.path.realpath( | ||
os.path.join(os.getcwd(), os.path.dirname(__file__), "schema.sql") | ||
) | ||
cursor.execute(open(path, "r").read(), []) |
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