Skip to content

babamiri/FastAPISQLAlchemy2Practices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Project with SQLAlchemy 2 and Alembic

This is a FastAPI project utilizing SQLAlchemy 2 for ORM and Alembic for database migrations.

Setup

  1. Clone the repository:

    git clone <repository_url>
    cd <project_folder>
  2. Install dependencies:

    pip install -r requirements.txt
  3. Setup environment variables:

    • Copy the provided env.example file to .env:

      cp env.example .env
    • Modify .env file according to your environment configuration.

  4. Database Setup:

    • Ensure your database server is up and running.
    • Modify the SQLAlchemy database URI in the .env file to point to your database.
  5. Run Alembic Migrations:

    alembic revision --autogenerate -m "create models"    
    alembic upgrade head

    This command will apply all pending migrations to your database.

Running the FastAPI Application

Ensure that your environment is properly configured and your database is accessible.

uvicorn app.main:app --host 0.0.0.0 --port 8000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published