-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup the db connection and user model
- Loading branch information
Showing
10 changed files
with
42 additions
and
2 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,5 @@ | ||
DB_USERNAME=root | ||
DB_PASSWORD=password | ||
DB_HOST=localhost | ||
DB_NAME=dzmouhami | ||
DB_PORT=3306 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
DB_USERNAME = os.getenv("DB_USERNAME") | ||
DB_PASSWORD = os.getenv("DB_PASSWORD") | ||
DB_HOST = os.getenv("DB_HOST") | ||
DB_NAME = os.getenv("DB_NAME") | ||
DB_PORT = os.getenv("DB_PORT") | ||
URL_DB = f"mysql+pymysql://{DB_USERNAME}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" |
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,8 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from config.const_db import URL_DB | ||
|
||
engine = create_engine(URL_DB) | ||
Base = declarative_base() | ||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False) |
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.
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,13 @@ | ||
from config.db import Base | ||
from sqlalchemy import String, Column, Integer, Boolean, DateTime | ||
|
||
class User(Base): | ||
__tablename__ = "user" | ||
id = Column(Integer, primary_key=True, index=True) | ||
nom = Column(String(255)) | ||
prenom = Column(String(255)) | ||
email = Column(String(255), unique=True) | ||
password = Column(String(255)) | ||
isGoogleUser = Column(Boolean, default=False) | ||
createdAt = Column(DateTime) | ||
role = Column(String(255), default="user") |
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 +1,3 @@ | ||
fastapi | ||
fastapi | ||
PyMySql | ||
python-dotenv |