Skip to main content

Interface to the SingleStore database and cluster management APIs

Project description

SingleStoreDB Python Interface

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

Warning As of version v0.5.0, the parameter substitution syntax has changed from :1, :2, etc. for list parameters and :foo, :bar, etc. for dictionary parameters to %s and %(foo)s, %(bar)s etc., respectively.

Install

This package can be install from PyPI using pip:

pip install singlestoredb

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 improvents 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.8s 5.6s 30.2s 3.7s
fetchmany(1000) 37.4s 9.5s 6.9s 30.4s 3.8s
fetchone 38.2s 10.3s 7.0s 32.1s 4.8s
iter(cur) 38.3s 9.5s 6.9s 31.3s 4.5s

Unbuffered

PyMySQL MySQLdb mysql.connector SingleStore (pure Python) SingleStore
fetchall 39.0s 6.6s 5.6s 31.8s 3.8s
fetchmany(1000) 39.4s 7.0s 6.2s 31.5s 4.0s
fetchone 34.5s 9.2s 10.4s 33.6s 4.9s
iter(cur) 39.0s 9.1s 10.4s 32.3s 4.7s

License

This library is licensed under the Apache 2.0 License.

Resources

User agreement

SINGLESTORE, INC. ("SINGLESTORE") AGREES TO GRANT YOU AND YOUR COMPANY ACCESS TO THIS OPEN SOURCE SOFTWARE CONNECTOR ONLY IF (A) YOU AND YOUR COMPANY REPRESENT AND WARRANT THAT YOU, ON BEHALF OF YOUR COMPANY, HAVE THE AUTHORITY TO LEGALLY BIND YOUR COMPANY AND (B) YOU, ON BEHALF OF YOUR COMPANY ACCEPT AND AGREE TO BE BOUND BY ALL OF THE OPEN SOURCE TERMS AND CONDITIONS APPLICABLE TO THIS OPEN SOURCE CONNECTOR AS SET FORTH BELOW (THIS “AGREEMENT”), WHICH SHALL BE DEFINITIVELY EVIDENCED BY ANY ONE OF THE FOLLOWING MEANS: YOU, ON BEHALF OF YOUR COMPANY, CLICKING THE “DOWNLOAD, “ACCEPTANCE” OR “CONTINUE” BUTTON, AS APPLICABLE OR COMPANY’S INSTALLATION, ACCESS OR USE OF THE OPEN SOURCE CONNECTOR AND SHALL BE EFFECTIVE ON THE EARLIER OF THE DATE ON WHICH THE DOWNLOAD, ACCESS, COPY OR INSTALL OF THE CONNECTOR OR USE ANY SERVICES (INCLUDING ANY UPDATES OR UPGRADES) PROVIDED BY SINGLESTORE. BETA SOFTWARE CONNECTOR

Customer Understands and agrees that it is being granted access to pre-release or “beta” versions of SingleStore’s open source software connector (“Beta Software Connector”) for the limited purposes of non-production testing and evaluation of such Beta Software Connector. Customer acknowledges that SingleStore shall have no obligation to release a generally available version of such Beta Software Connector or to provide support or warranty for such versions of the Beta Software Connector for any production or non-evaluation use.

NOTWITHSTANDING ANYTHING TO THE CONTRARY IN ANY DOCUMENTATION, AGREEMENT OR IN ANY ORDER DOCUMENT, SINGLESTORE WILL HAVE NO WARRANTY, INDEMNITY, SUPPORT, OR SERVICE LEVEL, OBLIGATIONS WITH RESPECT TO THIS BETA SOFTWARE CONNECTOR (INCLUDING TOOLS AND UTILITIES).

APPLICABLE OPEN SOURCE LICENSE: Apache 2.0

IF YOU OR YOUR COMPANY DO NOT AGREE TO THESE TERMS AND CONDITIONS, DO NOT CHECK THE ACCEPTANCE BOX, AND DO NOT DOWNLOAD, ACCESS, COPY, INSTALL OR USE THE SOFTWARE OR THE SERVICES.

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

Uploaded Source

Built Distributions

singlestoredb-0.5.0-cp36-abi3-win_amd64.whl (181.9 kB view details)

Uploaded CPython 3.6+ Windows x86-64

singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (210.4 kB view details)

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

singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (213.2 kB view details)

Uploaded CPython 3.6+ manylinux: glibc 2.17+ ARM64

singlestoredb-0.5.0-cp36-abi3-macosx_10_15_universal2.whl (191.2 kB view details)

Uploaded CPython 3.6+ macOS 10.15+ universal2 (ARM64, x86-64)

singlestoredb-0.5.0-cp36-abi3-macosx_10_9_universal2.whl (192.4 kB view details)

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

File details

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

File metadata

  • Download URL: singlestoredb-0.5.0.tar.gz
  • Upload date:
  • Size: 151.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for singlestoredb-0.5.0.tar.gz
Algorithm Hash digest
SHA256 883128015196ee735c28ace8740d7f5c66e55a41c9f373ef92ac2cd337fb1ac8
MD5 611b9c50d6d0467de7ec15ce08d3214c
BLAKE2b-256 d5bbaccba578af8e17fe061583eb4c841c93a5bd1408c94e023390f8d5beaa43

See more details on using hashes here.

File details

Details for the file singlestoredb-0.5.0-cp36-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for singlestoredb-0.5.0-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a31f0cac1af376a7590bd7b1168e03787457ba71f0429657dd974f9bfd19bf7b
MD5 6ab64efb36ad5b8f62f47f7bf41825ae
BLAKE2b-256 68bf962f0c1d26d9e3676df26a51d684fe8fb854d3c4617f2783a332a8da0f29

See more details on using hashes here.

File details

Details for the file singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58a866d344cf433d578954a7ba8ef846bd94c680ee75bcba712952e4f0d1cd04
MD5 3847e7506c58d958a3becd0a47fb46ec
BLAKE2b-256 fea7844e20529d1a20edefbe7646a1d44886edf66ee08c443a829bddfbf86aa6

See more details on using hashes here.

File details

Details for the file singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for singlestoredb-0.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 10b405e4d81b6bd2c4ed88a5d840e2ad422a482ccfff9576fd4959b4c520025c
MD5 1ff16b3147e05cd15af0246c6e13ebcd
BLAKE2b-256 20bdb44cc98ad591914d843ed674724ee4dd031a8bd98aba4805280f286f5471

See more details on using hashes here.

File details

Details for the file singlestoredb-0.5.0-cp36-abi3-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for singlestoredb-0.5.0-cp36-abi3-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 083151a2405f36492b1653aa0ef800beb9c51f565856fe9352bf6252e8ec1108
MD5 006448ebac48e1b3dc4bfaa9ca510b7f
BLAKE2b-256 36cce215118ecb89d9f5ec00ce470fd9a755b7bbc91e119a1354c9978bbe26b1

See more details on using hashes here.

File details

Details for the file singlestoredb-0.5.0-cp36-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for singlestoredb-0.5.0-cp36-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d890584627d503ea939aa70d89c0b41207e463c1b3b0a117dc040bf6f4e6102a
MD5 5ef8ba50e5167479b80693d206c299e7
BLAKE2b-256 cc00f939fba81fc57611372cf7761d71e67a97aef90a677f1b7d8386206bb5a2

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