-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from microsoft/login_azure
add login with azure and db with user
- Loading branch information
Showing
8 changed files
with
85 additions
and
19 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
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,24 @@ | ||
import os | ||
import duckdb | ||
|
||
class Database: | ||
def __init__(self, cache, db_name) -> None: | ||
if not os.path.exists(cache): | ||
os.makedirs(cache) | ||
|
||
db_path = os.path.join(cache, f'{db_name}.db') | ||
self.connection = duckdb.connect(database=db_path) | ||
|
||
def create_table(self, name, attributes = []): | ||
self.connection.execute(f"CREATE TABLE IF NOT EXISTS {name} ({', '.join(attributes)})") | ||
|
||
def select_embedding_from_hash(self, hash_text, username = ''): | ||
return self.connection.execute(f"SELECT embedding FROM embeddings WHERE hash_text = '{hash_text}' and username = '{username}'").fetchone() | ||
|
||
def insert_into_embeddings(self, hash_text, embedding, username = ''): | ||
self.connection.execute(f"INSERT INTO embeddings VALUES ('{username}','{hash_text}', {embedding})") | ||
|
||
def execute(self, query): | ||
return self.connection.execute(query) | ||
|
||
|
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,14 @@ | ||
from util.session_variable import SessionVariable | ||
import pandas as pd | ||
import util.session_variable as sv | ||
import os | ||
|
||
class SessionVariables: | ||
|
||
def __init__(self, prefix): | ||
self.narrative_input_df = SessionVariable(pd.DataFrame(), prefix) | ||
self.mode = sv.SessionVariable(os.environ.get("MODE", "dev")) | ||
self.username = sv.SessionVariable('') | ||
|
||
|
||
|
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
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.