PyBulk is a Python module that to allow simple and fast bulk data insertion into databases
Project description
PyBulk 🚀
简体中文 | English
PyBulk is a Python module that wraps PyMySQL to allow simple and fast bulk data insertion into databases. With PyBulk, you can insert thousands of records into a database table in just a few lines of code.
PyBulk builds on top of the PyMySQL library and connection pool to efficiently reuse connections and minimize latency. It handles all the low-level details of executing multiple INSERT statements while protecting your database from overload.
Some of the main features of PyBulk include:
- Simple API: Insert bulk data with just a few function calls. No complicated setup required.
- Speed: Leverages PyMySQL's connection pool to quickly insert thousands of records.
- Reliability: Includes error handling and recovery mechanisms to handle transient database errors. Retries failed queries automatically.
- Support for REPLACE INTO: Upsert support allows you to replace existing records in a table or insert new ones.
- Compatibility: Works with MySQL, MariaDB and AWS RDS. Compatible with Python 2 and 3.
PyBulk allows you to focus on your application's logic rather than spending time building infrastructure to handle database load. It is a robust but lightweight solution ideal for batch data processing applications.
💾 Installation
pip install pybulk
🔧 Usage:
import pybulk
cfg = {
'host': 'localhost',
'port': 3306,
'user': 'root',
'password': 'root',
'db': 'info',
'charset': 'utf8',
}
db = pybulk.client(cfg)
my_data = [
{'name': 'Peter', 'age': 21,},
{'name': 'Harry', 'age': 35,},
{'name': 'Mark', 'age': 40,},
]
db.push_data('student', my_data, size=2000)
# You can also run sql in pybulk like:
data = db.excute_sql('select * from school')
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybulk-0.2.13.tar.gz.
File metadata
- Download URL: pybulk-0.2.13.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b4a41b8f6eac93c389f4835a83068b5c6b54548915b28b5cb66d52b2e7cd8a5
|
|
| MD5 |
0452fc3ca443b137f28d984bf3aa19be
|
|
| BLAKE2b-256 |
788494b897088b750a4a3137333742a02347c9570a2ba47abe2a8ff35e7c64e6
|
File details
Details for the file pybulk-0.2.13-py3-none-any.whl.
File metadata
- Download URL: pybulk-0.2.13-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5ef4d5ab4a79c2c3b72ae9a670a241d88460f438544334d253be2037f69757c
|
|
| MD5 |
9ce9526b57c67417cd88161ffc8fa4ae
|
|
| BLAKE2b-256 |
1c076fbf55d1e6225aebd6a8610c2911cd8b84798628935d089688d7ce6dec32
|