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.1.0.tar.gz (257.1 kB view details)

Uploaded Source

Built Distributions

singlestoredb-1.1.0-py3-none-any.whl (274.1 kB view details)

Uploaded Python 3

singlestoredb-1.1.0-cp38-abi3-win_amd64.whl (302.6 kB view details)

Uploaded CPython 3.8+ Windows x86-64

singlestoredb-1.1.0-cp38-abi3-win32.whl (303.6 kB view details)

Uploaded CPython 3.8+ Windows x86

singlestoredb-1.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.0 kB view details)

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

singlestoredb-1.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.9 kB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

singlestoredb-1.1.0-cp38-abi3-macosx_10_9_universal2.whl (325.6 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for singlestoredb-1.1.0.tar.gz
Algorithm Hash digest
SHA256 125fe02907cdc7c3d2f6be1a89a2d1318977ce799634d765ac235413137ba20e
MD5 4621e4efa7093da52ebaa510cc6cbf04
BLAKE2b-256 b2fcc2c94c05d9f16fd2ff94f152f4213c0fcf1d7068757d15f8c26694567b1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d628a37a9a19d3042a699729699a991d22dd98ee92f3f0f2eca33e3eebd19996
MD5 51caf46acca7042ca8f0a09c4d06a985
BLAKE2b-256 83ef319768293203f9d2becfccc225f3d32f81a28297e87d64521e7e98a82682

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c05bca1d28d8c2ed69e56efc98f2e50cc3d9e826e8b0a55d60838a7b0aad9610
MD5 845423d6cb999e54a1362afc3189ecd5
BLAKE2b-256 9317e6e4d1c8a1e0b893f3d611543e62125784d71a25bbffb100b6e2a73bc0b5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for singlestoredb-1.1.0-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 7386af09c1f1a650049771c8ee8c732e80fcbe52a63b5a093dcc75fe420f7b5c
MD5 fcdf143bdb1fa6207a21a5cd4524bb4c
BLAKE2b-256 d5d6d3a9260f798e3458c433dbb6d3efcac48c775657bd3bb76b9e48670bcc40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2634479f0e6c2cfd2309069ed310093f240ddeaf2cad57c14d6d5785adfac4da
MD5 be25b8083fe60817806544baaf59b333
BLAKE2b-256 cf5ae2c3c09355a6f8f69620f459163df93ef2947fb32afe6f0745d2358199a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7c60dda5253731a48d2a89507edc8152689d516b8860d39ebdaba399eca900af
MD5 356717e80418753dd1b2f73656937663
BLAKE2b-256 0c88219643048d36c8d81ef3a8f8d28cde3f0251e2cf909d9d475948e37cb69a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.1.0-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0002a7f23d3ccbe73c1da6b390e5f25a9d489f48ea3a4ebb5e9aaa1ed26a34cf
MD5 8988ea4784babb608b4ac71d5c7403f9
BLAKE2b-256 26de5aedf00c5cce2244c16494275327af6ef2f60d1848823100f1ab1cfc27e2

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