Skip to content

n-km/api-sql-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

api-sql-connect

FastAPI connected to SQLite

Project

This is a simplified FastAPI setup connected to SQLite. It has a basic register + login flow, and you can list users.

The schema is simple: store email (unique) and password in the sqlite database. For testing purposes, the password is saved as-is.

Endpoints

  • POST /register => create a new user in the database. Body: {"email":"example@mail.com","password":"yourpassword"}
  • POST /login => check if email+password exists. Body: {"email":"example@mail.com","password":"yourpassword"}
  • GET /users => returns all users (id + email).

CORS

The API has CORS enabled for all origins, so a frontend can call it directly.

Database

The file data.db is a fresh new generated database for the project. If you want to be safe, just delete the file and run the API. The file will be created automatically.

Run the FastAPI

python -m uvicorn main:app --reload --port 19999

Documentation

Just build your own documentation of this project with pdoc.

How I installed pdoc:

python -m pip install pdoc

Run local server

python -m pdoc app

Generate docs (for static use):

$env:PYTHONPATH = ".\app"
python -m pdoc ./app

Now, you have a ./doc folder and can enter the index.html locally.

IF YOU DONT WANT TO BUILD BY YOURSELF

  • Use the existing .docs/index.html
  • May, It's not an updated version

About

FastAPI connected to SQLite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages