-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
032eb55
commit 5d9cf22
Showing
6 changed files
with
31 additions
and
383 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Nom de base de données | ||
DB_NAME= | ||
# Utilisateur | ||
DB_USER= | ||
# Mot de passe | ||
DB_PASSWORD= | ||
# Host Mysql | ||
DB_HOST= | ||
# Clé sécrète generée avec | ||
SECRET_KEY= |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,25 +1,17 @@ | ||
# initialize_db.py | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
import time | ||
import mysql.connector | ||
from app import db, app | ||
load_dotenv() | ||
|
||
def wait_for_db(): | ||
while True: | ||
try: | ||
conn = mysql.connector.connect( | ||
host=app.config['SQLALCHEMY_DATABASE_URI'].split('@')[1].split('/')[0].split(':')[0], | ||
user=app.config['SQLALCHEMY_DATABASE_URI'].split('//')[1].split(':')[0], | ||
password=app.config['SQLALCHEMY_DATABASE_URI'].split(':')[2].split('@')[0] | ||
) | ||
conn.close() | ||
break | ||
except mysql.connector.Error as err: | ||
print("Waiting for MySQL to be ready...") | ||
time.sleep(5) | ||
print(f"DB_HOST={os.getenv('DB_HOST')}") | ||
print(f"DB_USER={os.getenv('DB_USER')}") | ||
print(f"DB_PASSWORD={os.getenv('DB_PASSWORD')}") | ||
print(f"DB_NAME={os.getenv('DB_NAME')}") | ||
print(f"SECRET_KEY={os.getenv('SECRET_KEY')}") | ||
|
||
wait_for_db() | ||
from app import db | ||
from config import db_config | ||
|
||
with app.app_context(): | ||
db.create_all() | ||
print(f"DB Config: {db_config}") | ||
|
||
db.create_all() |
Oops, something went wrong.