https://github.com/gabrielhora/streamer
Stream PostgreSQL queries using NDJSON
https://github.com/gabrielhora/streamer
flask ndjson postgresql python python3
Last synced: 2 days ago
JSON representation
Stream PostgreSQL queries using NDJSON
- Host: GitHub
- URL: https://github.com/gabrielhora/streamer
- Owner: gabrielhora
- Created: 2017-06-16T03:39:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-16T03:42:02.000Z (over 8 years ago)
- Last Synced: 2025-03-16T14:30:23.559Z (7 months ago)
- Topics: flask, ndjson, postgresql, python, python3
- Language: Python
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Streamer
Simple way to stream any single PostgreSQL query using [NDJSON](http://ndjson.org/).
## How to use
There is a single endpoint `POST /` with two parameters, `query` and `params`.
These are some body examples:
```json
{
"query": "SELECT * FROM table WHERE field = %s",
"params": ["value"]
}
``````json
{
"query": "SELECT * FROM table WHERE int_field = %(param1)s AND str_field = %(param2)s",
"params": {
"param1": 123,
"param2": "value2"
}
}
```## Running
Run locally:
```
$ pip install virtualenv
$ virtualenv venv
$ . venv\bin\activate
(venv) $ pip install -r requirements.txt
(venv) $ python app/main.py
```Or use docker:
```
$ docker build -t streamer .
$ docker run --rm -p 80:80 streamer
```