Skip to content

Commit 13c4674

Browse files
PyExasol documentation added (#27)
* sales forecating demo added in examples adjusted file size * fixed some notebook documentation * fixed download link * rectified documentation * rectified documentation * pyexasol docs added
1 parent 93577b5 commit 13c4674

File tree

6 files changed

+171
-0
lines changed

6 files changed

+171
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Establishing a Connection
2+
==============================
3+
4+
5+
6+
The **connect()** method creates a connection to the database and returns an object **ExaConnection**.
7+
8+
The following example show how to connect with Exasol.
9+
10+
.. code-block:: python
11+
12+
import pyexasol
13+
14+
try:
15+
# Connect to Exasol
16+
connection = pyexasol.connect(dsn='127.0.0.1',
17+
user='scott',
18+
password='password')
19+
print("Connected successfully to Exasol.")
20+
except Exception as e:
21+
print(f"Error: {e}")
22+
23+
For additional parameter list please visit `ExaConnection API ref <https://exasol.github.io/pyexasol/master/api.html#pyexasol.ExaConnection>`_.
24+
To handle connection errors, use the try statement and catch all errors using the errors.Error exception:
25+
26+
27+
28+
29+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Querying Using PyExasol
2+
=========================================
3+
4+
In this section, we will create a table and insert data inside that table using PyExasol.
5+
The schema we are working with in this example is named 'SCHEMA'. You can replace it with your own schema name.
6+
7+
8+
Creating a Table
9+
----------------------
10+
11+
Using the **execute** method of the connection object we created earlier in the :ref:`installation-pyexasol` section.
12+
We are creating a table called **Employee**.
13+
14+
.. code-block:: python
15+
16+
create_table = connection.execute("CREATE OR REPLACE TABLE SCHEMA.Employee(employee_id INT PRIMARY KEY, " \
17+
"name VARCHAR(50), " \
18+
"hire_date DATE)")
19+
20+
For more information about the **execute** method. Check out `ExaConnection.execute class <https://exasol.github.io/pyexasol/master/_modules/pyexasol/connection.html#ExaConnection.execute>`_.
21+
22+
23+
Inserting Data into the Table
24+
------------------------------------
25+
26+
Using Pandas DataFrame
27+
^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
This is an example of inserting values into the "EMPLOYEE" table using pandas dataframe.
30+
31+
.. code-block:: python
32+
33+
data = {
34+
"employee_id": [15, 20, 30, 40, 50],
35+
"name": ['John', 'Jane', 'Michael', 'Emily', 'David'],
36+
"hire_date": ['2023-01-15', '2022-07-10', '2021-03-05', '2023-06-20', '2020-11-12'],
37+
}
38+
df_employees = pd.DataFrame(data)
39+
connection.import_from_pandas(df_employees, ('SCHEMA', 'EMPLOYEE'))
40+
41+
For custom params check out `ExaConnection.import_from_pandas <https://exasol.github.io/pyexasol/master/api.html#pyexasol.ExaConnection.import_from_pandas>`_
42+
43+
Using a file
44+
^^^^^^^^^^^^^^
45+
46+
.. code-block:: python
47+
48+
inserting_a_file = connection.import_from_file('file.csv', ('SCHEMA','EMPLOYEE'))
49+
50+
Make sure to that your file has the same column names as your table.
51+
52+
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>`_
53+
54+
55+
Retrieving Data From the Database
56+
------------------------------------
57+
58+
Like importing there are multiple options of **retrieving** data using PyExasol.
59+
Here is an example of exporting data into a pandas dataframe.
60+
61+
.. code-block:: python
62+
63+
retrieve_into_pandas = connection.export_to_pandas('SELECT * FROM SCHEMA.EMPLOYEE')
64+
print(retrieve_into_pandas.shape)
65+

doc/connect_to_exasol/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
PyExasol (Connect with Python)
3+
==============================================
4+
5+
Welcome to PyExasol, Exasol's proprietary Python connector.
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
10+
overview.rst
11+
installation.rst
12+
connection.rst
13+
first-querry.rst
14+
15+
16+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.. _installation-pyexasol:
2+
3+
Installation
4+
================
5+
6+
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:
7+
8+
.. code-block:: bash
9+
10+
pip install pyexasol
11+
12+
13+
Optional Dependencies
14+
------------------------
15+
16+
PyExasol can also be installed with sets of optional dependencies to enable certain functionality.
17+
18+
.. code-block:: bash
19+
20+
pip install pyexasol[optional-package-name]
21+
22+
- ``orjson`` is required for ``json_lib=orjson`` to improve JSON parsing performance.
23+
- ``pandas`` is required for importing_and_exporting_data functions working with :class:`pandas.DataFrame`.
24+
- ``polars`` is required for importing_and_exporting_data functions working with :class:`polars.DataFrame`.
25+
- ``pyarrow`` is required for importing_and_exporting_data functions working with :class:`pyarrow.parquet`.
26+
- ``pproxy`` is used in the examples to test an HTTP proxy.
27+
- ``rapidjson`` is required for ``json_lib=rapidjson`` to improve JSON parsing performance.
28+
- ``ujson`` is required for ``json_lib=ujson`` to improve JSON parsing performance.

doc/connect_to_exasol/overview.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
===========
2+
Overview
3+
===========
4+
5+
Exasol is compatible with a wide range of technologies.
6+
7+
PyExasol is the officially supported Python connector for Exasol. It helps to handle massive volumes of data commonly associated with DBMS within python.
8+
9+
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.
10+
11+
12+
PyExasol Main concepts
13+
-----------------------
14+
15+
* Based on `WebSocket <https://github.com/exasol/websocket-api>`_ protocol.
16+
* Optimized for minimum overhead.
17+
* Easy integration with pandas, parquet, and polars via HTTP transport.
18+
* Compression to reduce network bottleneck.
19+
20+
System Requirements
21+
---------------------
22+
23+
* **Exasol >= 7.1**
24+
* **Python >= 3.9**
25+
26+
PyExasol Versions
27+
---------------------------
28+
29+
For the latest version and info about PyExasol versions, refer to the `version history <https://github.com/exasol/pyexasol/releases>`_
30+
31+
32+

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Documentation and resources for data scientists and programmatic users to perfor
1111
data_ingestion
1212
UDF/index.rst
1313
data_science/index.rst
14+
connect_to_exasol/index.rst
1415
examples/index.rst
1516
environments
1617
integrations

0 commit comments

Comments
 (0)