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.8.0.tar.gz
.
File metadata
- Download URL: singlestoredb-1.8.0.tar.gz
- Upload date:
- Size: 285.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f034d9b3977add39caf534bf76b12a988103d33345aa048b3bfb728246719eef |
|
MD5 | 5ed4fecb29c7cf480126e2a0b5bea2f6 |
|
BLAKE2b-256 | 1f59d5262aaa6996180c8b3b05cffe45c4c8a8a0c63686d6eec2e91d668e0549 |
File details
Details for the file singlestoredb-1.8.0-py3-none-any.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-py3-none-any.whl
- Upload date:
- Size: 308.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74dac2966d81d058639118b7766b86891cc8b9fec60b6ba494d3703bd6b3bbe9 |
|
MD5 | 156906eecbbd5d76c68d416663fbb35d |
|
BLAKE2b-256 | a21e2a4b1d3d1f5440525102f30912262e7eed63e16554ae839309c88f0cddb3 |
File details
Details for the file singlestoredb-1.8.0-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 338.0 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96a0817b4379395b7b66e5813a8c0821e5ce7234212720e9f2d2a21d8cdee54d |
|
MD5 | f56ef4020332b8cc7e61d8751868243a |
|
BLAKE2b-256 | 49af542ea305eb36efea436df7cfb2027656e019a8dfb0e6d652e36003a9a598 |
File details
Details for the file singlestoredb-1.8.0-cp38-abi3-win32.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-cp38-abi3-win32.whl
- Upload date:
- Size: 339.2 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 261e365f5870442d02c458ec7c521659236736bc39bbd492da6a8f2981cbff2a |
|
MD5 | e0b6964bc243153312e6854e568b09cf |
|
BLAKE2b-256 | 9617d82ef8c4537d1f049c42e2128028184e4d288e7f5549d319779a6ba25b80 |
File details
Details for the file singlestoredb-1.8.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 400.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a6d6f12c2d73e5cbe29ea48e8d2bc618e9160d1050167a5e75dbe45193ed4be |
|
MD5 | b1e43a42cf9a67b8cfa05f061e3c7ae3 |
|
BLAKE2b-256 | f23529a7644f28afca988fe233053a8a3fb09a70bbb2ee931a66236ba2eb6bb1 |
File details
Details for the file singlestoredb-1.8.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 398.0 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5a560b35a82e5386dca6e00c9e6103ddccefd45d7101cf843ed9b77a1fa0619 |
|
MD5 | 77ba1a71e88ab9d709d0a5ab835b9d35 |
|
BLAKE2b-256 | 248df4b8247c053310f3fa61e8614753002e228b0314a7041f0744edbdebde82 |
File details
Details for the file singlestoredb-1.8.0-cp38-abi3-macosx_10_9_universal2.whl
.
File metadata
- Download URL: singlestoredb-1.8.0-cp38-abi3-macosx_10_9_universal2.whl
- Upload date:
- Size: 361.6 kB
- Tags: CPython 3.8+, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d792aa6dadc3e24f6cd73c3bf8657b63b10de5a521998c88b101178a6ce74667 |
|
MD5 | 36d68e16a81a7a15ce9c9dafbc592b35 |
|
BLAKE2b-256 | 6b264e75fa90c5148659e0bedef61ec9e18957dccb9d02b66c8801ee59caa440 |