Create a Wheelfile for Exasol usage

for a python project #exasol #python

A JAR (Java Archive) file is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution. JAR files are similar to zip files, but JAR files can have additional metadata that specify how to run the contained files as an application.

A wheel is a newer type of Python package format that is designed to replace eggs. Like JAR files, wheels are designed to be a convenient distribution format for Python packages, and they can be more efficient to install than installing from source because they contain pre-compiled code. Wheels use the .whl file extension.

So, in short, a JAR file is a package file used in Java, while a wheel file is a package file used in Python.

pip install wheel

python -m pip install --upgrade pip

pip install check-wheel-contents

Create the wheel file

python setup.py bdist_wheel

Add with bucketfsexplorer to exaadmin

use it in exasol database
After adding the whl file für sqlparse i need to add a Exasol UDF Script:



CREATE OR REPLACE PYTHON3 SCALAR SCRIPT SQLPARSEP () RETURNS VARCHAR2(2000) AS import glob sys.path.extend(glob.glob('/buckets/bfsdefault/py/*')) import sqlparse;

def run(ctx): parsed = sqlparse.parse('select * from foo')[0] t = parsed.tokens return(str(t)) 
/

Excecute Script sqlparsep()

Get an error : Failed.. didn't find a library (which is added in 3.8)

So we need to add a language file in Exasol:
https://github.com/exasol/script-languages-release/releases

Then we can use it in the current session:

alter session set script_languages = 'PYTHON=builtin_python R=builtin_r JAVA=builtin_java PYTHON3=localzmq+protobuf:///bfsdefault/language/python-3.8-minimal-EXASOL-6.2.0_release?lang=python#buckets/bfsdefault/language/python-3.8-minimal-EXASOL-6.2.0_release/exaudf/exaudfclient_py3';

And now
Excecute Script sqlparsep()
works fine ..

Use a newer Python3 Version in Exasol for a specific SQL Session.

Help: sqllineage.cli — sqllineage 1.3.7 documentation