Skip to main content

Interface to the SingleStoreDB database and workspace management APIs

Project description

SingleStoreDB Python SDK

This project contains a DB-API 2.0 compatible Python interface to the SingleStore database and workspace management API.

Install

This package can be install from PyPI using pip:

pip install singlestoredb

Documentation

https://singlestore-labs.github.io/singlestoredb-python

Usage

Connections to the SingleStore database are made using the DB-API parameters host, port, user, password, etc, but they may also be done using URLs that specify these parameters as well (much like the SQLAlchemy package).

import singlestoredb as s2

# Connect using the default connector
conn = s2.connect('user:password@host:3306/db_name')

# Create a cursor
cur = conn.cursor()

# Execute SQL
cur.execute('select * from foo')

# Fetch the results
print(cur.description)
for item in cur:
    print(item)

# Close the connection
conn.close()

Connecting to the HTTP API is done as follows:

# Use the HTTP API connector
conn = s2.connect('https://user:password@host:8080/db_name')

Performance

While this package is based on PyMySQL which is a pure Python-based MySQL connector, it adds various performance enhancements that make it faster than most other connectors. The performance improvements come from changes to the data conversion functions, cursor implementations, and a C extension that is highly optimized to improve row data reading.

The package can be used both in a pure Python mode and as well as a C accelerated mode. Generally speaking, the C accelerated version of the client can read data 10X faster than PyMySQL, 2X faster than MySQLdb, and 1.5X faster than mysql.connector. All of this is done without having to install any 3rd party MySQL libraries!

Benchmarking was done with a table of 3,533,286 rows each containing a datetime, a float, and eight character columns. The data is the same data set used in this article. The client and server were running on the same machine and queries were made using fetchone, fetchall, fetchmany(1000), and an iterator over the cursor object (e.g., iter(cur)). The results are shown below.

Buffered

PyMySQL MySQLdb mysql.connector SingleStore (pure Python) SingleStore
fetchall 37.0s 8.7s 5.6s 29.0s 3.7s
fetchmany(1000) 37.4s 9.2s 6.2s 29.6s 3.6s
fetchone 38.2s 10.1s 10.2s 30.9s 4.8s
iter(cur) 38.3s 9.1s 10.2s 30.4s 4.4s

Unbuffered

PyMySQL MySQLdb mysql.connector SingleStore (pure Python) SingleStore
fetchall 39.0s 6.5s 5.5s 30.3s 5.5s
fetchmany(1000) 39.4s 7.0s 6.0s 30.4s 4.1s
fetchone 34.5s 8.9s 10.1s 30.8s 6.6s
iter(cur) 39.0s 9.0s 10.2s 31.4s 6.0s

License

This library is licensed under the Apache 2.0 License.

Resources

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

singlestoredb-1.4.2.tar.gz (268.1 kB view details)

Uploaded Source

Built Distributions

singlestoredb-1.4.2-py3-none-any.whl (286.3 kB view details)

Uploaded Python 3

singlestoredb-1.4.2-cp38-abi3-win_amd64.whl (315.6 kB view details)

Uploaded CPython 3.8+ Windows x86-64

singlestoredb-1.4.2-cp38-abi3-win32.whl (316.8 kB view details)

Uploaded CPython 3.8+ Windows x86

singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (378.8 kB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (376.4 kB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

singlestoredb-1.4.2-cp38-abi3-macosx_10_9_universal2.whl (339.4 kB view details)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file singlestoredb-1.4.2.tar.gz.

File metadata

  • Download URL: singlestoredb-1.4.2.tar.gz
  • Upload date:
  • Size: 268.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for singlestoredb-1.4.2.tar.gz
Algorithm Hash digest
SHA256 03fa397645ca9c2753f2916acbc084e5724d94b7d3bdcdc967b6a3ea4878168a
MD5 d15a0310e96775aec49d8bf3dac53350
BLAKE2b-256 450f0a65c6515fa0c1c8456d931e7789b104dd7e43fa6c728b926f8ec3f8589b

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for singlestoredb-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a4c25fe76f2221fe3132b2209b7c4ec17a427956424f4ab35b9a7c35d016e52a
MD5 d8b4dcb65105df828afc2e8fbe14112e
BLAKE2b-256 6d47b6b48abb6e9c37d677aac6bfaf6d63767f884cf9d529cc905019ea2bbd42

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for singlestoredb-1.4.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 09b313499196262816ee0673d37b94315e82fad0331ebe392ecaee95e1bd5954
MD5 d3d22a8f8068366e3f825458457d520d
BLAKE2b-256 9a4a440c06d509d74e423941696e93ca331627900c8b51555c8277139b390d0b

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-cp38-abi3-win32.whl.

File metadata

  • Download URL: singlestoredb-1.4.2-cp38-abi3-win32.whl
  • Upload date:
  • Size: 316.8 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for singlestoredb-1.4.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 bb6a94f1dfe48cce466becb9aa03dbbee043d3988c72aca013687c33bdbdad0a
MD5 c883bc21c148bc67b471cd4b4469b656
BLAKE2b-256 c7c43e978343741ab0c950b6b76ae138cebc984cf79248ef4e3c035042a2e662

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e301664df11a5e2f5f220dcbeeba3c9b8d15f7db0f7e36c595e041fd94a541ce
MD5 2d2f3462962cb4f67c3b6a1216db6b60
BLAKE2b-256 47316b24afb5b3fddf5ae45ad1379ab2d9188599fb5a8b5482809930a646401c

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for singlestoredb-1.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e24cf2602f9db145819284df99148e0891dd205836bf1bf7294385bc280a8128
MD5 460a7c52d5166a3db260e5a1afe16894
BLAKE2b-256 27ea7e0ceedff50ab5b1a8378cd18d09acfed862e04e29e3097659289f11d5fe

See more details on using hashes here.

Provenance

File details

Details for the file singlestoredb-1.4.2-cp38-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for singlestoredb-1.4.2-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 92e5868fc9511d5eea0427bcf1fc7752c1e11987005a45cfe5723331589e605e
MD5 c2765e2bd8d5738cf06e1ef574987c6d
BLAKE2b-256 9a4322b53c9ba4b7215ffe4e47548440c1b63fc0c7c24b72266ca7502c5e4225

See more details on using hashes here.

Provenance

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