Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybulk-0.2.19.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybulk-0.2.19-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pybulk-0.2.19.tar.gz.

File metadata

  • Download URL: pybulk-0.2.19.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

Hashes for pybulk-0.2.19.tar.gz
Algorithm Hash digest
SHA256 a9f66007295dba78fdbd944ce302588d8ec483cc1c7807129954d86705b15c14
MD5 2e97aaba1e3d777807d5857908e86e0d
BLAKE2b-256 28269d3d6c0be48845fb7c4615f0480680329dca75aa6807bf7f6a479f4f3dff

See more details on using hashes here.

File details

Details for the file pybulk-0.2.19-py3-none-any.whl.

File metadata

  • Download URL: pybulk-0.2.19-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

Hashes for pybulk-0.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 7e008fbe65104b1f67e7475f9d7c2b5bad6781314d99b7f5a1c64f294a3f0c9f
MD5 52ed227a2d4eed0f6838136dd7625e0a
BLAKE2b-256 c9cc791d1d595a1705094a9eef22be78cbc1a96165810f592a39f408c39b3a3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page