Skip to main content

A client library for Featurebase.

Project description

python-featurebase

Python client for Featurebase SQL endpoint.

For more complete documentation, see:

https://docs.featurebase.com/docs/tools/python-client-library/python-client-library-home/

Client Library Usage:

First install the python-featurebase package. Running make from project folder will build and install the package. After installing the package you can try executing queries as shown in the following examples:

import featurebase

# assuming featurebase runs at "localhost:10101"
# for cloud, pass hostport="query.featurebase.com/v2", database="<database_id>", apikey="<APIKey_secret>"
# create client
client = featurebase.client()

# query the endpoint with SQL
try:
    result = client.query("SELECT * from demo;")
    print(result.data)
except Exception as e:
    # SQL errors and connection errors both come back as exceptions
    print(e)

# query the endpoint with a batch of SQLs, running the SQLs synchronously
# Synchronous run best suited for executing DDL and DMLs that need to follow specific run order
# passing the optional parameter "stoponerror=True" will stop execution at the failed SQL and the remaining SQLs in the list will not be executed. 
sqllist=[]
sqllist.append("CREATE TABLE demo1(_id id, i1 int);")
sqllist.append("INSERT INTO demo1(_id, i1) VALUES(1, 100);")
sqllist.append("INSERT INTO demo1(_id, i1) VALUES(2, 200);")
sqllist.append("select * from demo1;")
results = client.querybatch(sqllist, stoponerror=True)
for result in results:
    print(result.data)
    
# query the endpoint with a batch of SQLs, running the SQLs Asynchronously
# Asynchronous run best suited for running SELECT queries that can be run concurrently.
sqllist=[]
sqllist.append("SELECT * from demo1;")
sqllist.append("SELECT count(*) from demo1;")
sqllist.append("SELECT max(i1) from demo1;")
results = client.querybatch(sqllist, asynchronous=True)
for result in results:
    print(result.data)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

featurebase-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file featurebase-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: featurebase-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for featurebase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 713ab76bc70f438daf3af75a76648163d1cdc97b0c6ad9e3c0bfa407e338a682
MD5 22813cbaf2c1fdf3d598a02fcaf64894
BLAKE2b-256 da1ea76b268b73035733db6eb10f469a10588b87deb397690789790891115e5c

See more details on using hashes here.

Supported by

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