Skip to main content

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.
  • page_size: The size of the 'page', when doing paging. By default will use num_rows and in any way the page size it won't exceed num_rows.
  • page: Which page to fetch, starting from page 0

/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.

  • headers: 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. Finally, the content for a column may be fetched from a different field in the query output, by specifying the field name after a < character.

    Example: Fiscal Year:number<fiscal_year;Leap Year:yesno<0;

Example: For the following SQL:

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

headers 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/'
    )

Metadata

Release files for apisql 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apisql 0.9.0
File Size Uploaded
apisql-0.9.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apisql 0.9.0
File Interpreter ABI Platform
apisql-0.9.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 28.5 kB

Release files / apisql-0.9.0.tar.gz

Download URL apisql-0.9.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c87f61340270dfb57dacc6ca3f52428c5041b019041293512c9377b6c97f2c35
BLAKE2b-256 checksum
How to use checksums
2a24456bccea86593ccf581044629c0dd85b4028ae7a82dc05a6b0f21adce42d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / apisql-0.9.0-py2.py3-none-any.whl

Download URL apisql-0.9.0-py2.py3-none-any.whl
Size 20.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e5ffecb10d203a53a52a573322265cc1c3c878a9a8fbed043c77bfae8ef8804e
BLAKE2b-256 checksum
How to use checksums
6d2a3b525cc36d5cc31f0dda3f949640741dbf57fddd3ba9e2ab134c41eacd49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page