Skip to content
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
29 changes: 29 additions & 0 deletions doc/connect_to_exasol/connection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Establishing a Connection
==============================



The **connect()** method creates a connection to the database and returns an object **ExaConnection**.

The following example show how to connect with Exasol.

.. code-block:: python

import pyexasol

try:
# Connect to Exasol
connection = pyexasol.connect(dsn='127.0.0.1',
user='scott',
password='password')
print("Connected successfully to Exasol.")
except Exception as e:
print(f"Error: {e}")

For additional parameter list please visit `ExaConnection API ref <https://exasol.github.io/pyexasol/master/api.html#pyexasol.ExaConnection>`_.
To handle connection errors, use the try statement and catch all errors using the errors.Error exception:





65 changes: 65 additions & 0 deletions doc/connect_to_exasol/first-querry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Querying Using PyExasol
=========================================

In this section, we will create a table and insert data inside that table using PyExasol.
The schema we are working with in this example is named 'SCHEMA'. You can replace it with your own schema name.


Creating a Table
----------------------

Using the **execute** method of the connection object we created earlier in the :ref:`installation-pyexasol` section.
We are creating a table called **Employee**.

.. code-block:: python

create_table = connection.execute("CREATE OR REPLACE TABLE SCHEMA.Employee(employee_id INT PRIMARY KEY, " \
"name VARCHAR(50), " \
"hire_date DATE)")

For more information about the **execute** method. Check out `ExaConnection.execute class <https://exasol.github.io/pyexasol/master/_modules/pyexasol/connection.html#ExaConnection.execute>`_.


Inserting Data into the Table
------------------------------------

Using Pandas DataFrame
^^^^^^^^^^^^^^^^^^^^^^^

This is an example of inserting values into the "EMPLOYEE" table using pandas dataframe.

.. code-block:: python

data = {
"employee_id": [15, 20, 30, 40, 50],
"name": ['John', 'Jane', 'Michael', 'Emily', 'David'],
"hire_date": ['2023-01-15', '2022-07-10', '2021-03-05', '2023-06-20', '2020-11-12'],
}
df_employees = pd.DataFrame(data)
connection.import_from_pandas(df_employees, ('SCHEMA', 'EMPLOYEE'))

For custom params check out `ExaConnection.import_from_pandas <https://exasol.github.io/pyexasol/master/api.html#pyexasol.ExaConnection.import_from_pandas>`_

Using a file
^^^^^^^^^^^^^^

.. code-block:: python

inserting_a_file = connection.import_from_file('file.csv', ('SCHEMA','EMPLOYEE'))

Make sure to that your file has the same column names as your table.

There are multiple options to import data from using PyExasol. Check out more options from `here <https://exasol.github.io/pyexasol/master/api.html#pyexasol.ExaConnection.import_from_callback>`_


Retrieving Data From the Database
------------------------------------

Like importing there are multiple options of **retrieving** data using PyExasol.
Here is an example of exporting data into a pandas dataframe.

.. code-block:: python

retrieve_into_pandas = connection.export_to_pandas('SELECT * FROM SCHEMA.EMPLOYEE')
print(retrieve_into_pandas.shape)

16 changes: 16 additions & 0 deletions doc/connect_to_exasol/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

PyExasol (Connect with Python)
==============================================

Welcome to PyExasol, Exasol's proprietary Python connector.

.. toctree::
:maxdepth: 2

overview.rst
installation.rst
connection.rst
first-querry.rst



28 changes: 28 additions & 0 deletions doc/connect_to_exasol/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. _installation-pyexasol:

Installation
================

PyExasol is distributed through `PyPI <https://pypi.org/project/pyexasol/>`_ . It can be installed via pip, poetry, or any other type of dependency management tool:

.. code-block:: bash

pip install pyexasol


Optional Dependencies
------------------------

PyExasol can also be installed with sets of optional dependencies to enable certain functionality.

.. code-block:: bash

pip install pyexasol[optional-package-name]

- ``orjson`` is required for ``json_lib=orjson`` to improve JSON parsing performance.
- ``pandas`` is required for importing_and_exporting_data functions working with :class:`pandas.DataFrame`.
- ``polars`` is required for importing_and_exporting_data functions working with :class:`polars.DataFrame`.
- ``pyarrow`` is required for importing_and_exporting_data functions working with :class:`pyarrow.parquet`.
- ``pproxy`` is used in the examples to test an HTTP proxy.
- ``rapidjson`` is required for ``json_lib=rapidjson`` to improve JSON parsing performance.
- ``ujson`` is required for ``json_lib=ujson`` to improve JSON parsing performance.
32 changes: 32 additions & 0 deletions doc/connect_to_exasol/overview.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
===========
Overview
===========

Exasol is compatible with a wide range of technologies.

PyExasol is the officially supported Python connector for Exasol. It helps to handle massive volumes of data commonly associated with DBMS within python.

PyExasol provides an API to read & write multiple data streams in parallel using separate processes, which is necessary to fully utilize hardware and achieve linear scalability. With PyExasol you are no longer limited to a single CPU core.


PyExasol Main concepts
-----------------------

* Based on `WebSocket <https://github.com/exasol/websocket-api>`_ protocol.
* Optimized for minimum overhead.
* Easy integration with pandas, parquet, and polars via HTTP transport.
* Compression to reduce network bottleneck.

System Requirements
---------------------

* **Exasol >= 7.1**
* **Python >= 3.9**

PyExasol Versions
---------------------------

For the latest version and info about PyExasol versions, refer to the `version history <https://github.com/exasol/pyexasol/releases>`_



2 changes: 2 additions & 0 deletions doc/data_science/ai_architecture/bfs.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _bucket-fs:

BucketFS
===================

Expand Down
14 changes: 7 additions & 7 deletions doc/examples/sales_forecasting/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ What You'll Need
You’ll need to:

* Set up `AI-Lab <https://github.com/exasol/ai-lab>`_ (We recommend the Docker version because it comes with the Docker database. Alternatively, you can use `Exasol SaaS <https://cloud.exasol.com>`_).
* Download the .sql file.
* Download and import the notebooks zip file from :ref:`setup-sf`.

What You'll Learn
-----------------
Expand All @@ -38,8 +38,8 @@ In this demo, you will learn how to:

* **Build a forecasting model**: Train a sales forecasting model using XGBoost in JupyterLab.
* **Integrate with Exasol**: Connect JupyterLab to Exasol and use it as both a data source and deployment target.
* **Deploy ML models inside the database**: Upload a trained model into Exasol and register it as a User-Defined Function (UDF).
* **Run predictions (UDFs) with SQL queries**: Execute forecasts directly within Exasol using standard SQL, without moving data outside the database.
* **Deploy ML models inside the database**: Upload a trained model into :ref:`bucket-fs`.
* **Run predictions (UDFs) with SQL queries**: Execute forecasts directly within Exasol using standard SQL, without moving data outside the database using :ref:`overview-label`.
* **Leverage Exasol’s AI architecture**: Understand how Exasol enables in-database machine learning workflows for speed, scalability, and simplicity.

What You'll Build
Expand All @@ -48,7 +48,7 @@ What You'll Build
In this demo, you will build a complete in-database machine learning workflow for sales forecasting:

* A **sales forecasting model** trained with XGBoost in JupyterLab.
* A deployment pipeline to **upload the trained model into Exasol**.
* An :ref:`overview-label` inside Exasol that encapsulates the model logic.
* A way to run predictions directly in Exasol using SQL queries.
* An end-to-end example of Exasol’s AI architecture in action — from model saving to in-database prediction.
* A deployment pipeline to **upload the trained model** into :ref:`bucket-fs`.
* A :ref:`overview-label` inside Exasol that encapsulates the model logic.
* A way to run predictions directly in the database using SQL queries.
* An end-to-end example of Exasol’s AI architecture in action — from model saving to in-database predictions.
9 changes: 7 additions & 2 deletions doc/examples/sales_forecasting/setup.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.. _setup-sf:


Setup
======

You will use `AI-Lab <https://github.com/exasol/ai-lab>`_ and an Exasol database. You can choose the Docker DB that comes with AI-Lab or
You will be needing `AI-Lab <https://github.com/exasol/ai-lab>`_ and an Exasol database. You can choose the Docker DB that comes with AI-Lab or
use `Exasol SaaS <https://cloud.exasol.com>`_ and start with the free trial.

Once you have finished setting up with `AI-Lab <https://github.com/exasol/ai-lab>`_, we can proceed.
Expand All @@ -15,6 +18,8 @@ If this is your first time using `AI-Lab <https://github.com/exasol/ai-lab>`_, f
* Go through all of the cells in the `main_config` file.
* You have multiple database options: Docker (recommended), SaaS, and On-Prem.
* The last cell creates a **schema** for you and ensures that you are connected to a database.
* We can now proceed with our demo.


Download the Sales Forecasting Demo File
------------------------------------------
Expand All @@ -23,7 +28,7 @@ Download the Sales Forecasting Demo File
* **Extract** the contents of the .zip file using your file explorer.
* **Create** a folder inside the root folder of AI-Lab and name it "sales_forecasting".
* **Upload** the files inside extracted folder into the "sales_forecasting" folder. Using the import button on the top right.
* **Alternatively** you just upload the .zip file to JupyterLabs and unzip it using :ref:`below`.
* **Alternatively** you can just upload the .zip file to JupyterLabs and unzip it using :ref:`below`.
* **Congratulations!** You’re all set, and now **we shall meet in AI-Lab**.
* The notebooks are **numbered** so you can know which one to visit **first**.

Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Documentation and resources for data scientists and programmatic users to perfor
data_ingestion
UDF/index.rst
data_science/index.rst
connect_to_exasol/index.rst
examples/index.rst
environments
integrations
Expand Down