Skip to content

Innosphere-Bridger/PAGE_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Database Management API

File Structure

  • database.db --> a database that has populated data in it.
  • main.py --> the code for the structure and the API endpoints
  • populate_database.py --> this code when run puts FAKE data into the database
  • requirements.txt --> holds packages along with their versions to be installed

main.py documentation

This FastAPI-based project provides a RESTful API for managing entities, users, access groups, readers, sensors, measurements, and point types in an SQLite database using SQLModel. It includes CRUD operations for each entity and allows relationships between them.

Features

  • Entity, User, Access Group, Reader, Sensor, Measurement, and Point Type management
  • SQLite database integration
  • Automatic database creation and test data population
  • FastAPI-based RESTful endpoints
  • Relationship management using SQLModel

Installation

  1. Clone the repository:

    git clone <repository_url>
    cd <project_directory>
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts�ctivate`
  3. Install dependencies:

    pip install -r requirements.txt

Running the Application

Start the FastAPI server:

uvicorn main:app --reload

This will start the API server at http://127.0.0.1:8000/.

Testing the API

You can use Swagger UI to interact with the API. The "testDataCreate" tool will populate the database.

Alternatively, test API calls using curl or tools like Postman.

Database Setup

The database is automatically created when the application starts. Test data can be populated using:

curl -X POST http://127.0.0.1:8000/testDataCreate

API Endpoints

Entity Management

  • Create Entity: POST /entity/
  • Delete Entity: DELETE /entity/{entity_id}
  • Update Entity: PATCH /entity/{entity_id}

User Management

  • Create User: POST /user/
  • Delete User: DELETE /user/{user_id}
  • Update User: PATCH /user/{user_id}

Access Group Management

  • Create Access Group: POST /accessgroup/
  • Delete Access Group: DELETE /accessgroup/{accessgroup_id}
  • Update Access Group: PATCH /accessgroup/{accessgroup_id}

Reader Management

  • Create Reader: POST /reader/
  • Delete Reader: DELETE /reader/{reader_id}
  • Update Reader: PATCH /reader/{reader_id}

Sensor Management

  • Create Sensor: POST /sensor/
  • Delete Sensor: DELETE /sensor/{sensor_id}
  • Update Sensor: PATCH /sensor/{sensor_id}

Measurement Management

  • Create Measurement: POST /measurement/
  • Delete Measurement: DELETE /measurement/{measurement_id}
  • Update Measurement: PATCH /measurement/{measurement_id}

Point Type Management

  • Create Point Type: POST /pointtype/
  • Delete Point Type: DELETE /pointtype/{pointtype_id}
  • Update Point Type: PATCH /pointtype/{pointtype_id}

License

This project is not Licensed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages