Skip to main content

A flask blueprint providing a read-lny API for querying RDBMS

Project description

apisql

PyPI - Python Version

apisql is a flask blueprint providing an API for read-only access for a DBMS using direct SQL Queries

endpoints

/query

Returns query results in json format.

Query parameters that can be send:

  • query: The SQL query to execute on the DB. The query can be provided in plain text or base64 encoded.
  • num_rows: The maximum number of rows to return. If not specified, will return the aount defined in the configuration, the amount defined in the environment variable APISQL__MAX_ROWS or 100.

/download

Downloads query results in either csv, xls or xlsx format.

Query parameters that can be send:

  • query: The SQL query to execute on the DB. The query can be provided in plain text or base64 encoded.
  • format: Either csv or xlsx. Defaults to csv.
  • filename: The filename for the file to be downloaded, without the extension. Defaults to query-results.
  • formatters: A semicolon separated list of the headers for the output file. Headers should match the field names that appear in the query. Headers may contain one or more modifiers, which appear after a colon. The currently supported modifiers are:
    • number, to convert numeric values to strings
    • yesno, which converts boolean values to "Yes" / "No"
    • comma-separated, which converts arrays of strings to a comma separated list of these strings.

Example: For the following SQL:

select employee_name as "Employee Name", employee_salary as "Salary", is_manager as "Managerial role?" from employees

formatters could be specified as Employee Name;Managerial role?:yesno;Salary:number.

configuration

Flask configuration for this blueprint:

    from apisql import apisql_blueprint

    app.register_blueprint(
        apisql_blueprint(connection_string='psql://host/database', max_rows=1000, debug=False),
        url_prefix='/api/db/'
    )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apisql-0.1.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

apisql-0.1.4-py2.py3-none-any.whl (19.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file apisql-0.1.4.tar.gz.

File metadata

  • Download URL: apisql-0.1.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.8

File hashes

Hashes for apisql-0.1.4.tar.gz
Algorithm Hash digest
SHA256 12b5b4ff817b393806139d81369fc5126bdc03ac60d700702c32ca681769566b
MD5 717e2ef011b6ead1187078974585ca47
BLAKE2b-256 36b398b4a46d802c932a73cef0c1d4adc8bffc839f0e2377f905d9034f49355d

See more details on using hashes here.

Provenance

File details

Details for the file apisql-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: apisql-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.8

File hashes

Hashes for apisql-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b8f156636e60a7a4cad31e01f9d357546fefb4da2431580108d98c28b7fb91a9
MD5 c18424fff3949d42c431f972f093d133
BLAKE2b-256 7401926fc7ea81007ab417fc68bde0e32a6a8dcdbe741f1f14a96fc6516535d6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page