This is a bug tracker
If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.
Please complete the following information:
OS: windows 11
Psycopg version: 2.9.6
Python version: 3.12.1
PostgreSQL version:16
pip version: 24.0
config.py:
import os
from dotenv import load_dotenv
as config is not where main.py, so we have to declaer the path
from pathlib import Path
env_path = Path(".") / ".env"
print(env_path)
load_dotenv(dotenv_path=env_path)
class Setting:
PROJECT_TITLE: str = "Pradipta Blog Apis"
PROJECT_VERSION: str = "0.1.0"
This is a bug tracker If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.
Please complete the following information:
config.py: import os from dotenv import load_dotenv
as config is not where main.py, so we have to declaer the path
from pathlib import Path
env_path = Path(".") / ".env"
print(env_path)
load_dotenv(dotenv_path=env_path)
class Setting: PROJECT_TITLE: str = "Pradipta Blog Apis" PROJECT_VERSION: str = "0.1.0"
settings = Setting()
session.py: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker
from core.config import settings from typing import Generator
SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL print("Database url is ", SQLALCHEMY_DATABASE_URL) engine = create_engine(SQLALCHEMY_DATABASE_URL) print("Database url is-------- ", SQLALCHEMY_DATABASE_URL) SESSIONLOCAL = sessionmaker(autoflush=False, autocommit=False, bind=engine)
def get_db() -> Generator: try: db = SESSIONLOCAL() yield db finally: db.close()
requirements.txt: fastapi==0.100.0 uvicorn==0.22.0
SQLAlchemy==2.0.13 psycopg2==2.9.6
python-dotenv==1.0.0
alembic==1.11.1
pydantic[email]
passlib[bcrypt]
all are installed and virtualenv activated.. --------------Error---------------- When Running unvicorn main:app --reload getting this error