Skip to content

Jose-Nt/api-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PostgreSQL API

πŸ“„ Description

This project provides a Flask-based API for internal PostgreSQL data access. It establishes connections to a PostgreSQL database and executes SQL queries to retrieve and structure. This API is intended exclusively for internal use within a secure infrastructure. It is deployed on a remote Linux server and used as part of Airflow-managed data pipelines, streamlining interactions between ETL workflows and PostgreSQL databases eliminating the need to import PostgreSQL interaction modules in each pipeline.

Notes

  • Credentials and access are restricted to internal systems and trusted services;
  • In trusted indoor environments, it is possible to adapt the system to hold fixed credentials;
  • Used to simplify data acquisition within automated data pipelines;

Features

  • Connects to a PostgreSQL database using user-supplied credentials;
  • Fetches all data based on SQL querys and returns it in JSON format;
  • Basic data type handling for JSON compatibility;

Endpoints

GET /query/<user>/<password>/<host>/<dbname>/<query>

Fetches and returns data based on a SQL query. Example:

GET /query/myuser/mypassword/dbhost/dbname/SELECT * FROM table_x LIMIT 5

πŸ—‚οΈ Project Structure

project-root/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/                # API route definitions
β”‚   β”œβ”€β”€ db/                 # DB connection and queries
β”‚   β”œβ”€β”€ services/           # Data formatting logic
β”‚   └── main.py             # Application entry point
β”‚
β”œβ”€β”€ requirements.txt      
└── README.md

Running the API

  1. Clone the repository:
git clone https://github.com/Jose-Nt/api-postgresql.git
cd api-postgresql
  1. Install dependencies:
pip install -r requirements.txt
  1. Start the API:
python src/main.py

πŸ‘€ Authors

  • JosΓ© Neto Souza (Jose-Nt)

License

Free use permitted β€” attribution required.

About

Flask-based API for internal PostgreSQL data access simplifying data pipelines integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages