Skip to main content
"stackql logo"

PyStackQL - Python Wrapper for StackQL

Documentation Status PyPI

StackQL is an open source developer tool which allows you to query and interact with cloud and SaaS provider APIs using SQL grammar. StackQL can be used for cloud inventory analysis, cloud cost optimization, cloud security and compliance, provisioning/IaC, assurance, XOps, and more.

PyStackQL is a Python wrapper for StackQL which allows you to use StackQL within Python applications and to use the power of Python to extend StackQL. PyStackQL can be used with pandas, matplotlib, plotly, jupyter and other Python libraries to create powerful data analysis and visualization applications.

For detailed documentation, including the API reference, see Read the Docs.

Installing PyStackQL

PyStackQL can be installed with pip as follows:

pip install pystackql

You can install from source by cloning this repository and running a pip install command in the root directory of the repository:

git clone https://github.com/stackql/pystackql
cd pystackql
pip install .

Using PyStackQL

The following example demonstrates how to run a query and return the results as a pandas.DataFrame:

from pystackql import StackQL
import pandas as pd
region = "ap-southeast-2"
stackql = StackQL()

query = """
SELECT instanceType, COUNT(*) as num_instances
FROM aws.ec2.instances
WHERE region = '%s'
GROUP BY instanceType
""" % (region)

res = stackql.execute(query)
df = pd.read_json(res)
print(df)

You can find more examples in the stackql docs or the examples in readthedocs.

Supported Operating Systems

PyStackQL (and StackQL) are supported on:

  • MacOS (arm and amd)

  • Linux

  • Windows

Supported Python Versions

PyStackQL has been tested on:

  • Python 3.7

  • Python 3.8

  • Python 3.9

  • Python 3.10

  • Python 3.11

Licensing

PyStackQL is licensed under the MIT License. The license is available here

Building the docs

To build the docs, you will need to install the following packages:

pip install sphinx sphinx_rtd_theme sphinx-autodoc-typehints

Then, from the root directory of the repository, run:

cd docs
make html

The docs will be built in the docs/build/html directory.

Building the package

To build the package, you will need to install the following packages:

pip install setuptools wheel twine

Then, from the root directory of the repository, run:

python3 setup.py sdist

The package will be built in the dist directory.

Publishing the package

To publish the package to PyPI, run the following command:

twine upload dist/pystackql-2.0.2.tar.gz

Metadata

Release files for pystackql 2.0.2

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

Source distribution (sdist)

Source distribution for pystackql 2.0.2
File Size Uploaded
pystackql-2.0.2.tar.gz 7.2 kB Details

Release files / pystackql-2.0.2.tar.gz

Download URL pystackql-2.0.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a259e308992a54f4ad776312a9faaaae72a7c4ee0350b7752e88eed601ec0079
BLAKE2b-256 checksum
How to use checksums
ef66a57e72d763ed1a7e28ef7aefee856b0a86eac1832b727f2fc15ac3ceb37c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

3.8.4

2 release files

3.8.3

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.5

2 release files

3.6.4

2 release files

3.6.3

2 release files

3.6.2

1 release file

3.6.1

1 release file

3.6.0

1 release file

3.5.7

1 release file

3.5.6

1 release file

3.5.5

1 release file

3.5.4

1 release file

3.5.3

1 release file

3.5.2

1 release file

3.5.1

1 release file

3.5.0

1 release file

3.2.5

1 release file

3.2.4

1 release file

3.2.3

1 release file

3.2.2

1 release file

3.2.1

1 release file

3.2.0

1 release file

3.1.2

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.0.3

1 release file

This release

2.0.2 This release

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.5.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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