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.
- 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;
- 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;
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-root/
β
βββ src/
β βββ api/ # API route definitions
β βββ db/ # DB connection and queries
β βββ services/ # Data formatting logic
β βββ main.py # Application entry point
β
βββ requirements.txt
βββ README.md
- Clone the repository:
git clone https://github.com/Jose-Nt/api-postgresql.git
cd api-postgresql- Install dependencies:
pip install -r requirements.txt- Start the API:
python src/main.py- JosΓ© Neto Souza (Jose-Nt)
Free use permitted β attribution required.