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
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Type of Change
<!--- Check any relevant boxes with "x" -->
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Task

### Description

### TESTS
<!--- Specify number of tests added or changed -->
Number of tests added/changed:

### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Enter the ticket number as TP-XXXX format -->
- [ ] Removes existing feature
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
42 changes: 42 additions & 0 deletions .github/workflows/install-dependencies-and-run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Python package new version
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Update pip version
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
pip install -r test/requirements.txt
- name: Build new version of the package
run: |
python -m build
- name: Install the new version of the package
run: |
pip install dist/*.tar.gz
- name: Test with pytest
env:
HOSTNAME: ${{ secrets.HOSTNAME }}
PORT: ${{ secrets.PORT }}
ONTOLOGY: ${{ secrets.ONTOLOGY }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
ENABLED_SSL: ${{ secrets.ENABLED_SSL }}
HTTP_PATH: ${{ secrets.HTTP_PATH }}
run: |
pytest
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
.vscode/launch.json

# C extensions
*.so
Expand Down Expand Up @@ -50,7 +51,11 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
test.py
test/env*
test/.python-version
test/.env
test/run*
test/*old*

# Translations
*.mo
Expand Down Expand Up @@ -110,7 +115,6 @@ venv/
ENV/
env.bak/
venv.bak/
.vscode

# Spyder project settings
.spyderproject
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
![Timbr logo](https://timbr.ai/wp-content/uploads/2023/06/timbr-ai-l-5-226x60-1.png)

![MIT License](https://img.shields.io/badge/License-MIT-green)
![GPL-2.0 License](https://img.shields.io/badge/License-GPL--2.0-green)
![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-green)
![Timbr logo](https://timbr.ai/wp-content/uploads/2025/01/logotimbrai230125.png)

[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B50508%2Fgithub.com%2FWPSemantix%2Ftimbr_python_connector.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B50508%2Fgithub.com%2FWPSemantix%2Ftimbr_python_connector?ref=badge_shield&issueType=license)
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B50508%2Fgithub.com%2FWPSemantix%2Ftimbr_python_connector.svg?type=shield&issueType=security)](https://app.fossa.com/projects/custom%2B50508%2Fgithub.com%2FWPSemantix%2Ftimbr_python_connector?ref=badge_shield&issueType=security)

[![Python 3.7.13](https://img.shields.io/badge/python-3.7.13+-blue)](https://www.python.org/downloads/release/python-3713/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue)](https://www.python.org/downloads/release/python-3820/)
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue)](https://www.python.org/downloads/release/python-3921/)
[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-31017/)
[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-31112/)
[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3129/)

[![Java 11](https://img.shields.io/badge/Java-11-red)](https://www.oracle.com/il-en/java/technologies/javase/jdk11-archive-downloads.html)
[![Java 17](https://img.shields.io/badge/Java-17-red)](https://www.oracle.com/il-en/java/technologies/javase/jdk17-archive-downloads.html)
Expand All @@ -21,12 +18,13 @@
This project is a python connector to timbr using JDBC.

## Dependencies
- Python 3.7.13+ or 3.8.x or 3.9.x
- Access to a timbr-server
- Python from 3.9.13 or newer
- Java 11 or Java 17 or Java 21

## Installation
- Install as clone repository:
- Install Python: https://www.python.org/downloads/release/python-3713/
- Install Python: https://www.python.org/downloads/release/python-3913/
- Install Java: https://www.oracle.com/il-en/java/technologies/javase/jdk11-archive-downloads.html
- Run the following command to install the Python dependencies: `pip install -r requirements.txt` (optional install pandas to run pandas example)
- Download the following jar to `jars` path: https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/4.0.1/hive-jdbc-4.0.1-standalone.jar
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
File renamed without changes.
108 changes: 54 additions & 54 deletions PyTimbr/timbr_connector.py → pytimbr/timbr_connector.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
#
# *### ., @%
# *%## `#// %%%* *@ `` @%
# #*. * .%%%` @@@@* @@ @@@@,@@@@ @&@@@@ .&@@@*
# #%%# .. *@ @@ @` @@` ,@ @% #@ @@
# ,, .,%(##/./%%#, *@ @@ @` @@` ,@ @% #@ @@
# ,%##% `` `/@@* @@ @` @@` ,@ (/@@@#/ @@
# ``
# ``````````````````````````````````````````````````````````````
# Copyright (C) 2018-2024 timbr.ai
#

from . import timbr_jdbapi
import os
import platform
import pathlib

main_jar_path = os.environ.get('TIMBR_JDBC_JAR_PATH', os.path.join(pathlib.Path(__file__).parent.resolve(), 'jars'))
jdbc_driver = 'org.apache.hive.jdbc.HiveDriver'

def get_combined_jars_path(maindir):
jar_dir = os.walk(maindir)
jars_array = []
for _root, _dirs, files in jar_dir:
for filename in files:
if filename.find('.jar') > 0:
jars_array.append(os.path.join(maindir, filename))
jars = ":".join(jars_array)
if "Windows" in platform.platform():
jars = ";".join(jars_array)

return jars

jars_path = get_combined_jars_path(main_jar_path)

def get_jdbc_connection(jdbc_url, username, password):
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn

def get_connection(hostname, port, ontology, username, password, enabled_ssl = 'true', http_path = '/timbr-server'):
jdbc_url = f"jdbc:hive2://{hostname}:{port}/{ontology};transportMode=http;ssl={enabled_ssl};httpPath={http_path}"
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn

# Deprecated - Backward compatibility

def getJdbcConnection(jdbc_url, username, password):
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn

def getConnection(hostname, port, ontology, username, password, enabled_ssl = True, http_path = '/timbr-server'):
jdbc_url = f"jdbc:hive2://{hostname}:{port}/{ontology};transportMode=http;ssl={enabled_ssl};httpPath={http_path}"
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn
#
# *### ., @%
# *%## `#// %%%* *@ `` @%
# #*. * .%%%` @@@@* @@ @@@@,@@@@ @&@@@@ .&@@@*
# #%%# .. *@ @@ @` @@` ,@ @% #@ @@
# ,, .,%(##/./%%#, *@ @@ @` @@` ,@ @% #@ @@
# ,%##% `` `/@@* @@ @` @@` ,@ (/@@@#/ @@
# ``
# ``````````````````````````````````````````````````````````````
# Copyright (C) 2018-2024 timbr.ai
#
from . import timbr_jdbapi
import os
import platform
import pathlib
main_jar_path = os.environ.get('TIMBR_JDBC_JAR_PATH', os.path.join(pathlib.Path(__file__).parent.resolve(), 'jars'))
jdbc_driver = 'org.apache.hive.jdbc.HiveDriver'
def get_combined_jars_path(maindir):
jar_dir = os.walk(maindir)
jars_array = []
for _root, _dirs, files in jar_dir:
for filename in files:
if filename.find('.jar') > 0:
jars_array.append(os.path.join(maindir, filename))
jars = ":".join(jars_array)
if "Windows" in platform.platform():
jars = ";".join(jars_array)
return jars
jars_path = get_combined_jars_path(main_jar_path)
def get_jdbc_connection(jdbc_url, username, password):
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn
def get_connection(hostname, port, ontology, username, password, enabled_ssl = 'true', http_path = '/timbr-server'):
jdbc_url = f"jdbc:hive2://{hostname}:{port}/{ontology};transportMode=http;ssl={enabled_ssl};httpPath={http_path}"
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn
# Deprecated - Backward compatibility
def getJdbcConnection(jdbc_url, username, password):
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn
def getConnection(hostname, port, ontology, username, password, enabled_ssl = True, http_path = '/timbr-server'):
jdbc_url = f"jdbc:hive2://{hostname}:{port}/{ontology};transportMode=http;ssl={enabled_ssl};httpPath={http_path}"
conn = timbr_jdbapi.connect(jdbc_driver, jdbc_url, [username, password], jars_path)
return conn
Loading