Skip to main content

advancedEXASOL is a Python library that extends pyexasol's functionality.

Project description

advancedEXASOL

AdvancedEXASOL is a Python library that extends the functionality of pyEXASOL and allows for faster data manipulation using Dask. It includes features such as table management, data importing/exporting, and data merging. It also includes various decorators to ensure safe and efficient execution of SQL queries.

The AdvancedEXASOL library contains all the methods and has "decorators" which includes following: ensure_table_exists, ensure_connection, handle_transactions, sql_injection_safe, and enforce_resource_limits. These decorators are used to add additional functionality and safety measures to the methods in the AdvancedEXASOL class.

One of the main features of AdvancedEXASOL is the ability to create a new table from a external source like a Dask DataFrame or an existing EXASOL table using the create_table_from_df and create_table_from_table methods, respectively. It also has the ability to convert an EXASOL table to various formats, such as JSON, CSV, XML, and Excel, using the to_json, to_csv, to_xml, and to_excel methods.

In addition, AdvancedEXASOL allows for data to be imported and exported to and from Dask Dataframes using the import_from_dask and export_to_dask methods. This can be useful for interacting with larger datasets that may not fit in memory.

Finally, AdvancedEXASOL has the ability to merge two tables using the merge_tables method or merge two tables from external sources using the merge_from_external method. This allows for easy data consolidation and management.

Overall, AdvancedEXASOL aims to streamline the interaction between Python and the EXASOL database by providing a wide range of useful features and safety measures.

Features

AdvancedEXASOL includes the following features:

  • create_table_from_df: Create a new table from a Pandas Dataframe
  • create_table_from_table: Create a new table from an existing EXASOL table
  • export_to_dask: Export data from EXASOL to Dask Dataframe
  • import_from_dask: Import data from Dask Dataframe to EXASOL
  • to_pandas: Convert an EXASOL table to Pandas Dataframe
  • to_json: Convert an EXASOL table to JSON format
  • to_csv: Convert an EXASOL table to CSV format
  • csv_to_excel: Convert an EXASOL CSV to an Excel file
  • to_xml: Convert an EXASOL table to XML format
  • to_excel: Convert an EXASOL table to an Excel file
  • merge_tables: Merge two EXASOL tables
  • merge_from_external: Merge two tables from external sources

Requirements

AdvancedEXASOL requires the following modules:

Usage

AdvancedEXASOL has a class named Features which contains all the methods. It also has a script decorators which contains the following decorators:

  • ensure_table_exists: This decorator is used to check if a table exists in the EXASOL database before performing any operation on it. If the table does not exist, an error is raised. This is useful for ensuring that the desired table is available for use before trying to perform any actions on it.
  • ensure_connection: This decorator is used to ensure that a connection to the EXASOL database has been established before running any operation. If a connection has not been established, an error is raised. This is useful for preventing operations from being run without a valid connection to the database.
  • handle_transactions: This decorator is used to automatically handle transactions when performing any operation on the EXASOL database. Transactions allow multiple related SQL statements to be executed as a single unit of work, either all succeeding or all being rolled back if any of the statements fail. This decorator ensures that transactions are properly started and ended for each operation, helping to ensure the integrity of the data in the database.
  • sql_injection_safe: This decorator is used to sanitize input strings before running any operation on the EXASOL database. SQL injection is a type of security vulnerability that occurs when an attacker is able to send malicious code to a database through user input. This decorator helps to prevent such attacks by ensuring that input strings are properly escaped and validated before being used in an operation.
  • enforce_resource_limits: This decorator is used to enforce resource limits when performing any operation on the EXASOL database. Resource limits can be used to prevent certain operations from consuming too many resources, such as memory or CPU time, which could negatively impact the performance of the database. This decorator helps to ensure that resource limits are properly enforced for each operation, helping to maintain the performance and stability of the database.

Example

Here is an example of how to use advancedEXASOL:

Connect to the Exasol database
from advanced_exasol import Features

# Connect to EXASOL
conn = Features.connect('hostname', 'username', 'password')
Export to a dask dataframe and import from a dask dataframe via HTTP transport
# Export data from EXASOL to Dask Dataframe
df = conn.export_to_dask('existing_table')

# Import data from Dask Dataframe to EXASOL
conn.import_from_dask(df, 'new_table')

# Disconnect from EXASOL
conn.close()
Different methods to convert data from Exasol to other formats.
# Convert EXASOL table to Pandas Dataframe
df = conn.to_pandas('existing_table')

# Convert EXASOL table to JSON
json_string = conn.to_json('existing_table')

# Convert EXASOL table to CSV
conn.to_csv('existing_table', 'existing_table.csv')

# Convert EXASOL CSV to Excel file
conn.csv_to_excel('existing_table.csv', 'existing_table.xls')

# Convert EXASOL table to XML
xml_string = conn.to_xml('existing_table')

# Convert EXASOL table to Excel file
conn.to_excel('existing_table', 'existing_table.xls')

# Disconnect from EXASOL
conn.close()
Merge data from one table to another. It also supports simple select statements and CTEs.
# Connect to EXASOL
conn = Features.connect('hostname', 'username', 'password')

# Merge two EXASOL tables
conn.merge_tables('table1', 'table2', 'merged_table', 'column1, column2')

# Disconnect from EXASOL
conn.close()
Merge data from different data sources into the database..
# Connect to EXASOL
conn = Features.connect('hostname', 'username', 'password')

# Merge two tables from external sources
conn.merge_from_external('/path/to/table1.csv', '/path/to/table2.xls', 'merged_table', 'column1, column2')

# Disconnect from EXASOL
conn.close()

Documentation

The complete documentation for pyEXASOL can be found here.

License

AdvancedEXASOL is released under the MIT License.

Contributions

Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.

Contact

If you have any questions or feedback, please feel free to contact me via email at dfrigewski@gmail.com.

Thank you for using AdvancedEXASOL!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

advancedEXASOL-0.2.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distributions

advancedEXASOL-0.2.0-py3.11.egg (9.2 kB view details)

Uploaded Source

advancedEXASOL-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file advancedEXASOL-0.2.0.tar.gz.

File metadata

  • Download URL: advancedEXASOL-0.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for advancedEXASOL-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4269a34c2f8f2a9d4dbe12dcaacb92f90f05140fe719015682e2cfe317b4c593
MD5 9e521193db3defd89df084a01a2b1246
BLAKE2b-256 b46853a5cf2463d27845d579f74449aa28619bb7ddeee364361600681e78ab47

See more details on using hashes here.

File details

Details for the file advancedEXASOL-0.2.0-py3.11.egg.

File metadata

  • Download URL: advancedEXASOL-0.2.0-py3.11.egg
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for advancedEXASOL-0.2.0-py3.11.egg
Algorithm Hash digest
SHA256 521ca583b2c585ec98d2a744e5cac253b3aeb73903ebd49ad9d4c3f7e034c20f
MD5 4cbae1dabb5834fc16040e974115a815
BLAKE2b-256 23bc3b4ad767ff268c5759727b12cc08be34015caf45d14d5f1af20a066e343a

See more details on using hashes here.

File details

Details for the file advancedEXASOL-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for advancedEXASOL-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4aad35308620c87f74f55781d4a4d9d57033ce3f04724e19e4442a0c1ecc584c
MD5 66b210fdf44de09c5d65ba0ecda40345
BLAKE2b-256 d8b8627129e7b4b84e9f6b9df6bee1b202f1c90310f09a6934dcd868bdfc1f93

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page