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

Uploaded Source

Built Distributions

singlestoredb-1.6.3-py3-none-any.whl (299.0 kB view details)

Uploaded Python 3

singlestoredb-1.6.3-cp38-abi3-win_amd64.whl (328.4 kB view details)

Uploaded CPython 3.8+ Windows x86-64

singlestoredb-1.6.3-cp38-abi3-win32.whl (329.6 kB view details)

Uploaded CPython 3.8+ Windows x86

singlestoredb-1.6.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (391.2 kB view details)

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

singlestoredb-1.6.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (388.4 kB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

singlestoredb-1.6.3-cp38-abi3-macosx_10_9_universal2.whl (352.0 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for singlestoredb-1.6.3.tar.gz
Algorithm Hash digest
SHA256 d2f0914aab912635a2e959991b4ea6a0f64085bc714fb25aa114e02f6f75f7a0
MD5 e4299d49b212c717009c641c0112316f
BLAKE2b-256 af4316ab2ee8c9ad9b445d0a0fc4a3542475ce405b3e818a274c5a780a0cacdc

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 496726f14e8b98098ac1a5542a243bc2fa5254ab47eb031862e633c718580c28
MD5 65200ab12602cc1c4b6a7e08aefc86af
BLAKE2b-256 d9690b5e285bb9ebc0269728d362bd6c645f7af6b0e285587beb0e54f2a0cd69

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.6.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 bd8d8bfdc5a44709d442d329d7174aca8d08991f2603af47492dd410b1026209
MD5 170e87547543af4721592d4b24b24b72
BLAKE2b-256 1956d3b9202932aff652e49c9fc7395fa47affa9b1103f9c4521a7ac4db61588

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: singlestoredb-1.6.3-cp38-abi3-win32.whl
  • Upload date:
  • Size: 329.6 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.6.3-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 b0f78214ee886322d0e86daf5ca7f8c9f7e529afeb5d470eac4c6df9317bb183
MD5 f491cc3a9a2f86f2864e48850d91cb39
BLAKE2b-256 ddf6b865ea5779e880ed2d0eaefde19a03d260bedec5a7bdc308eec6a8fcc5b6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.6.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 49f3d4ea38d374b875c518381a3718c0842d8ffe411403670184e59503438414
MD5 0cbd7a07d268cc4cc36f8c48e14dbac7
BLAKE2b-256 512a9ffb66dc5e08191ba76b761234ea038dbd49eea3006ef4f23aa18b3252d7

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.6.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4643e3df4812a93ee46b565145b30b3ed40976f8c32df2e1eb9b94fec36971e6
MD5 186c1951956afe22fb2b427325184b19
BLAKE2b-256 2578946bc27080555c8e8aa61d650facc0c7bd8fea68338bff0344e87411119e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for singlestoredb-1.6.3-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 5e79fd4a04e87b06799a3972d121c1d68afbd9ebb5b945f9536f6fd11e1f181a
MD5 ac886bb706556171554ca9e4fe101e19
BLAKE2b-256 212e3c1545cb856cd519b5d5639b1e82577e8058e344cd44e9154bf8a1888d7f

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