Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated docs #17

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
.. _StackQL: https://github.com/stackql/stackql

pystackql documentation
=======================
`StackQL`_ is a dev tool which allows you to query and interact with cloud provider APIs using a SQL language.
StackQL can be used for cloud inventory analysis, security audits, Infrastructure-as-Code, lifecycle operations (such as starting or stopping a VM).

The :mod:`pystackql` package is a Python library for using `StackQL <https://github.com/stackql/stackql>`_.
For information on the StackQL language specification, grammar and built-in functions, see the `StackQL documentation <https://stackql.io/docs>`_.
For StackQL provider information, see the `StackQL Provider Registry <https://registry.stackql.io/>`_.

.. toctree::
:maxdepth: 2
:caption: Contents

intro
examples
pystackql

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
.. _StackQL: https://github.com/stackql/stackql

pystackql documentation
=======================
`StackQL`_ is a dev tool which allows you to query and interact with cloud provider APIs using a SQL language.
StackQL can be used for cloud inventory analysis, security audits, Infrastructure-as-Code, lifecycle operations (such as starting or stopping a VM).

The :mod:`pystackql` package is a Python library for using `StackQL <https://github.com/stackql/stackql>`_.
For information on the StackQL language specification, grammar and built-in functions, see the `StackQL documentation <https://stackql.io/docs>`_.
For StackQL provider information, see the `StackQL Provider Registry <https://registry.stackql.io/>`_.

.. toctree::
:maxdepth: 2
:caption: Contents

intro
examples
pystackql
magic_ext

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
69 changes: 69 additions & 0 deletions docs/source/magic_ext.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
StackqlMagic Extension for Jupyter
==================================

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.

Setup
-----

To enable the `StackqlMagic` extension in your Jupyter notebook, use the following command:

.. code-block:: python

%load_ext pystackql

Usage
-----

The extension provides both line and cell magic functionalities:

1. **Line Magic**:

You can run StackQL queries directly from a single line:

.. code-block:: python

%stackql DESCRIBE aws.ec2.instances

2. **Cell Magic**:

For multi-line queries or when you need to use specific options:

.. code-block:: python

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

Options
-------

When using `StackqlMagic` as cell magic, you can pass in the following options:

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

Example:

.. code-block:: python

project = 'stackql-demo'
zone = 'australia-southeast1-a'
region = 'australia-southeast1'

.. code-block:: python

%%stackql --no-display
SELECT name, status
FROM google.compute.instances
WHERE project = '$project' AND zone = '$zone'

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.

.. note::

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.

--------

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.
12 changes: 0 additions & 12 deletions docs/source/pystackql.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
API Reference for pystackql
===========================

Module Contents
---------------
.. automodule:: pystackql
:members:
:undoc-members:

StackQL Class
-------------
.. autoclass:: pystackql.StackQL
Expand All @@ -15,10 +9,4 @@ StackQL Class
:undoc-members:
:show-inheritance:

StackqlMagic Class (Jupyter Magic Extension)
--------------------------------------------
.. autoclass:: pystackql.stackql_magic.StackqlMagic
:members:
:undoc-members:
:show-inheritance: