https://github.com/sebastianmahecha/traffic_offences
This project is a practice API. I'm using Python + FastApi, PostgreSQL and machine learning tools
https://github.com/sebastianmahecha/traffic_offences
api fastapi python
Last synced: 5 months ago
JSON representation
This project is a practice API. I'm using Python + FastApi, PostgreSQL and machine learning tools
- Host: GitHub
- URL: https://github.com/sebastianmahecha/traffic_offences
- Owner: SebastianMahecha
- Created: 2024-10-25T18:46:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-08T11:33:13.000Z (over 1 year ago)
- Last Synced: 2025-04-05T16:13:45.501Z (over 1 year ago)
- Topics: api, fastapi, python
- Language: Python
- Homepage:
- Size: 361 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# traffic_offences
RUN PROJECT
fastapi dev main.py
conda activate traffic_offences_env
create database traffic_offences_db;
CREATE ROLE traffic_offences_user WITH LOGIN PASSWORD '12345678';
grant all privileges on database traffic_offences_db to traffic_offences_user;
ALTER DATABASE traffic_offences_db OWNER TO traffic_offences_user;
psql -U traffic_offences_user -d traffic_offences_db
pip install fastapi uvicorn sqlalchemy asyncpg
Config automigrate
pip install alembic
alembic init alembic
Modificar el archivo env.py,
agregar el target_metadata
target_metadata = SQLModel.metadata
Reemplazar las urls de la DB en offline y online
DATABASE_URL = os.getenv("DATABASE_URL")
reemplazar el connectable del online
connectable = create_engine(DATABASE_URL)
importar los modelos del proyecto
from models import *
agregar la siguiente linea en el archivo script.py.mako
import sqlmodel # added
Crear migraciones
alembic revision --autogenerate -m "create user table"
correr migracion
alembic upgrade head