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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file singlestoredb-1.2.0.tar.gz
.
File metadata
- Download URL: singlestoredb-1.2.0.tar.gz
- Upload date:
- Size: 263.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 399e1f520164f424d5fff9d1f8e349a3d968e7e79d7b184a42e8e43bf142b9d9 |
|
MD5 | ee81330460e56a42bcb9257fb201cac6 |
|
BLAKE2b-256 | a4eb20e9c74c472f75c741b4b04b69a7d07b484be6faadc5bb1056e5f46c0809 |
Provenance
File details
Details for the file singlestoredb-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-py3-none-any.whl
- Upload date:
- Size: 280.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3601d9f004e4bd59752cf8d33f06551d03cb8d58f787833d7008a58d5a59bce |
|
MD5 | ceff2b4244db0d65a5fd612bdfcab417 |
|
BLAKE2b-256 | 3bbc04ff1582a864a96ba168aa73e8196745f8309f22f89158e2400bfb29f37a |
Provenance
File details
Details for the file singlestoredb-1.2.0-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 309.7 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d0ac7c0fb10c9d82c0a7d75a915228a1f9e0bf7bcadb410a3014da9bf13638a |
|
MD5 | 1d4213085ab9789781024d9f6ed66d25 |
|
BLAKE2b-256 | a78e86662d9ad11ff3f17954b0ee4d15b1e6adfa4a96491cd930c888a813b889 |
Provenance
File details
Details for the file singlestoredb-1.2.0-cp38-abi3-win32.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-cp38-abi3-win32.whl
- Upload date:
- Size: 310.8 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e00765b41a2a570156cde87e3967d13a3cab8272466a28c95eef155d776c431 |
|
MD5 | aad568b65c894d41e86e298c99167657 |
|
BLAKE2b-256 | 67d30a05a6428746236714bf3d1c830774c392387babca88ceab8e271519aae1 |
Provenance
File details
Details for the file singlestoredb-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 372.6 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abbea2229bff668625162380a029312a56392ce5e6b402187d8e02148f5f34b1 |
|
MD5 | eacb0aad859eff2cae13cf20cc44eece |
|
BLAKE2b-256 | 041427bfd41ebcaf4d1f908ea2192ad9db6f5f14cddd9d68adf7b36b646f5138 |
Provenance
File details
Details for the file singlestoredb-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 370.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 479e415e7f89030d399b40c3bdf5456dd0b7aef154cf895af532872882eb8d31 |
|
MD5 | d16a26f4154019504b6c95953da9432f |
|
BLAKE2b-256 | cb9c64bfae2b7b0bd1876920525d19f6f7c48014bb23c27162fca18f0ada6636 |
Provenance
File details
Details for the file singlestoredb-1.2.0-cp38-abi3-macosx_10_9_universal2.whl
.
File metadata
- Download URL: singlestoredb-1.2.0-cp38-abi3-macosx_10_9_universal2.whl
- Upload date:
- Size: 333.7 kB
- Tags: CPython 3.8+, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fe87cbb635a000e8ad9c6be477b85e37c43c1903985dfac58f226ef3572f5ca |
|
MD5 | 7139c62f467a68bd63c14dd0d7c6c58e |
|
BLAKE2b-256 | 48d6204a6c4fd2768d3375dfb88b87771d0d928c332625b345584ecf94246ded |