diff --git a/datastore/FertiScan/__init__.py b/datastore/FertiScan/__init__.py index b0b309d6..55a97b16 100644 --- a/datastore/FertiScan/__init__.py +++ b/datastore/FertiScan/__init__.py @@ -1,6 +1,6 @@ import os from dotenv import load_dotenv - +import uuid load_dotenv() diff --git a/datastore/__init__.py b/datastore/__init__.py index c253582a..86b59d36 100644 --- a/datastore/__init__.py +++ b/datastore/__init__.py @@ -113,7 +113,7 @@ async def new_user(cursor, email, connection_string, tier="user") -> User: async def get_user_container_client( - user_id, tier="user", storage_url=NACHET_STORAGE_URL + user_id, storage_url, account, key, tier="user" ): """ Get the container client of a user @@ -123,7 +123,7 @@ async def get_user_container_client( Returns: ContainerClient object """ - sas = blob.get_account_sas(NACHET_BLOB_ACCOUNT, NACHET_BLOB_KEY) + sas = blob.get_account_sas(account, key) # Get the container client container_client = await azure_storage.mount_container( storage_url, user_id, True, tier, sas diff --git a/datastore/db/__init__.py b/datastore/db/__init__.py index d58e006e..a43a64ed 100644 --- a/datastore/db/__init__.py +++ b/datastore/db/__init__.py @@ -1,25 +1,14 @@ """ This module contains the function interacting with the database directly. """ -import os + import psycopg from dotenv import load_dotenv load_dotenv() -# def connect_db(): -# """Connect to the postgresql database and return the connection.""" -# connection = psycopg.connect( -# conninfo=NACHET_DB_URL, -# autocommit=False, -# options=f"-c search_path={NACHET_SCHEMA},public") -# assert connection.info.encoding == 'utf-8', ( -# 'Encoding is not UTF8: ' + connection.info.encoding) -# # psycopg.extras.register_uuid() -# return connection - -def connect_db(conn_str : str = NACHET_DB_URL, schema :str = NACHET_SCHEMA): +def connect_db(conn_str: str, schema: str): """Connect to the postgresql database and return the connection.""" connection = psycopg.connect( conninfo=conn_str, @@ -45,14 +34,15 @@ def end_query(connection, cursor): connection.close() -def create_search_path(connection, cur,schema = NACHET_SCHEMA): +def create_search_path(connection, cur, schema): cur.execute(f"""SET search_path TO "{schema}";""") connection.commit() + if __name__ == "__main__": - connection = connect_db(FERTISCAN_DB_URL,FERTISCAN_SCHEMA) - print(FERTISCAN_DB_URL) + connection = connect_db("test", "test") + print("test") cur = cursor(connection) - create_search_path(connection, cur,FERTISCAN_SCHEMA) + create_search_path(connection, cur, "test") end_query(connection, cur) print("Connection to the database successful") diff --git a/doc/datastore.md b/doc/datastore.md index 0ebda026..a713d3e1 100644 --- a/doc/datastore.md +++ b/doc/datastore.md @@ -68,7 +68,9 @@ flowchart LR; ``` ## Database Architecture + For more detail on each app database architecture go check [Nachet Architecture](nachetArchitecture.md) and [Fertiscan Architecture](FertiscanArchitecture.md). + ### Global Needs - A User must be able to take a picture on the app and it must be saved in the @@ -78,4 +80,3 @@ flowchart LR; - A User can verify the result of a picture that went through the pipeline and the changes are saved for training. - diff --git a/doc/metadata-doc.md b/doc/metadata-doc.md index a5c68527..aa7ec342 100644 --- a/doc/metadata-doc.md +++ b/doc/metadata-doc.md @@ -45,7 +45,7 @@ process is complete, the upload process will come into play, enabling the distribution of the files between the BLOB storage and a PostgreSQL database. We are currently improving the process to make it more efficient across all our - project. + project. ``` mermaid