Skip to content
Snippets Groups Projects
Commit a7f25d7d authored by erichard's avatar erichard
Browse files

Accès à la base de données par os.environ['DATABASE']

parent 87419c4a
No related branches found
No related tags found
2 merge requests!61Packager labelstower,!60WIP: Implement sqlalchemy
import os
from typing import Dict, List from typing import Dict, List
from flask import current_app
def get_selected_elements(id_mandatory_labels: int, id_forbiden_labels: str, number_of_mandatory_labels: str) -> List[Dict[int, str]] : def get_selected_elements(id_mandatory_labels: int, id_forbiden_labels: str, number_of_mandatory_labels: str) -> List[Dict[int, str]] :
""" """
...@@ -198,7 +200,7 @@ def send_query_to_db(query: str) -> List[Dict[int, str]] : ...@@ -198,7 +200,7 @@ def send_query_to_db(query: str) -> List[Dict[int, str]] :
''' '''
import sqlite3 import sqlite3
result = [] result = []
with sqlite3.connect('app/voiture.db') as connexion: with sqlite3.connect(os.path.join('app', current_app.config['DATABASE'])) as connexion:
cursor = connexion.cursor() cursor = connexion.cursor()
response = cursor.execute(query) response = cursor.execute(query)
for row in response: for row in response:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment