Skip to content

Commit 3f6ea33

Browse files
authored
Merge pull request #17 from stackql/feature/refactor
updated docs
2 parents 5d17c05 + b7de364 commit 3f6ea33

File tree

3 files changed

+94
-36
lines changed

3 files changed

+94
-36
lines changed

docs/source/index.rst

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
.. _StackQL: https://github.com/stackql/stackql
2-
3-
pystackql documentation
4-
=======================
5-
`StackQL`_ is a dev tool which allows you to query and interact with cloud provider APIs using a SQL language.
6-
StackQL can be used for cloud inventory analysis, security audits, Infrastructure-as-Code, lifecycle operations (such as starting or stopping a VM).
7-
8-
The :mod:`pystackql` package is a Python library for using `StackQL <https://github.com/stackql/stackql>`_.
9-
For information on the StackQL language specification, grammar and built-in functions, see the `StackQL documentation <https://stackql.io/docs>`_.
10-
For StackQL provider information, see the `StackQL Provider Registry <https://registry.stackql.io/>`_.
11-
12-
.. toctree::
13-
:maxdepth: 2
14-
:caption: Contents
15-
16-
intro
17-
examples
18-
pystackql
19-
20-
Indices and tables
21-
==================
22-
23-
* :ref:`genindex`
24-
* :ref:`modindex`
1+
.. _StackQL: https://github.com/stackql/stackql
2+
3+
pystackql documentation
4+
=======================
5+
`StackQL`_ is a dev tool which allows you to query and interact with cloud provider APIs using a SQL language.
6+
StackQL can be used for cloud inventory analysis, security audits, Infrastructure-as-Code, lifecycle operations (such as starting or stopping a VM).
7+
8+
The :mod:`pystackql` package is a Python library for using `StackQL <https://github.com/stackql/stackql>`_.
9+
For information on the StackQL language specification, grammar and built-in functions, see the `StackQL documentation <https://stackql.io/docs>`_.
10+
For StackQL provider information, see the `StackQL Provider Registry <https://registry.stackql.io/>`_.
11+
12+
.. toctree::
13+
:maxdepth: 2
14+
:caption: Contents
15+
16+
intro
17+
examples
18+
pystackql
19+
magic_ext
20+
21+
Indices and tables
22+
==================
23+
24+
* :ref:`genindex`
25+
* :ref:`modindex`
2526
* :ref:`search`

docs/source/magic_ext.rst

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
StackqlMagic Extension for Jupyter
2+
==================================
3+
4+
The ``StackqlMagic`` extension for Jupyter notebooks provides a convenient interface to run SQL queries against the StackQL database directly from within the notebook environment. Results can be visualized in a tabular format using Pandas DataFrames.
5+
6+
Setup
7+
-----
8+
9+
To enable the `StackqlMagic` extension in your Jupyter notebook, use the following command:
10+
11+
.. code-block:: python
12+
13+
%load_ext pystackql
14+
15+
Usage
16+
-----
17+
18+
The extension provides both line and cell magic functionalities:
19+
20+
1. **Line Magic**:
21+
22+
You can run StackQL queries directly from a single line:
23+
24+
.. code-block:: python
25+
26+
%stackql DESCRIBE aws.ec2.instances
27+
28+
2. **Cell Magic**:
29+
30+
For multi-line queries or when you need to use specific options:
31+
32+
.. code-block:: python
33+
34+
%%stackql
35+
SELECT instanceType, COUNT(*) as num_instances
36+
FROM aws.ec2.instances
37+
WHERE region = '$region' GROUP BY instanceType
38+
39+
Options
40+
-------
41+
42+
When using `StackqlMagic` as cell magic, you can pass in the following options:
43+
44+
- **--no-display** : Suppresses the display of the results. Even when this option is enabled, the results are still saved in the `stackql_df` Pandas DataFrame.
45+
46+
Example:
47+
48+
.. code-block:: python
49+
50+
project = 'stackql-demo'
51+
zone = 'australia-southeast1-a'
52+
region = 'australia-southeast1'
53+
54+
.. code-block:: python
55+
56+
%%stackql --no-display
57+
SELECT name, status
58+
FROM google.compute.instances
59+
WHERE project = '$project' AND zone = '$zone'
60+
61+
This will run the query but won't display the results in the notebook. Instead, you can later access the results via the `stackql_df` variable.
62+
63+
.. note::
64+
65+
The results of the queries are always saved in a Pandas DataFrame named `stackql_df` in the notebook's current namespace. This allows you to further process or visualize the data as needed.
66+
67+
--------
68+
69+
This documentation provides a basic overview and usage guide for the `StackqlMagic` extension. For advanced usage or any additional features provided by the extension, refer to the source code or any other accompanying documentation.

docs/source/pystackql.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
API Reference for pystackql
22
===========================
33

4-
Module Contents
5-
---------------
6-
.. automodule:: pystackql
7-
:members:
8-
:undoc-members:
9-
104
StackQL Class
115
-------------
126
.. autoclass:: pystackql.StackQL
@@ -15,10 +9,4 @@ StackQL Class
159
:undoc-members:
1610
:show-inheritance:
1711

18-
StackqlMagic Class (Jupyter Magic Extension)
19-
--------------------------------------------
20-
.. autoclass:: pystackql.stackql_magic.StackqlMagic
21-
:members:
22-
:undoc-members:
23-
:show-inheritance:
2412

0 commit comments

Comments
 (0)