Skip to content

Commit

Permalink
Add package type hints (#158)
Browse files Browse the repository at this point in the history
* Add package type hints

* Add helper script to create schema
  • Loading branch information
jsangmeister committed Dec 8, 2021
1 parent c2b4e32 commit e6d9832
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Empty file added datastore/py.typed
Empty file.
17 changes: 17 additions & 0 deletions datastore/shared/postgresql_backend/create_schema.py
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(), [])
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
description="Package for OS4 to provide direct access to the datastore",
packages=setuptools.find_packages(),
install_requires=install_requires,
package_data={"datastore": ["py.typed", "shared/postgresql_backend/schema.sql"]},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit e6d9832

Please sign in to comment.