multy
Package that can be easily bulk inserted with MySQL / MariaDB of Python. You can also perform inserts and updates based on primary and unique keys.
Requirement
- Python3
- MySQL >= 5.5
- MariaDB >= 5.5
- Install PyMySQL or mysqlclient
Installation
pip install multy
Bulk Insert
Example of inserting into the following table
Table Name: sample
| Field | Type |
|---|---|
| id | int |
| age | int |
| name | varchar |
import multy
import pymysql
# pymysql or mysqlclient connection
con = pymysql.connect(user='', passwd='', host='localhost', db='')
# step1 The second argument is the table name
sample = multy.BulkQuery(con, 'sample')
for i in range(10):
# step2 {column name: value}
sample.add_record({
'id': 1,
'age': 28,
'name': 'test'
})
# step3 Insert execution
sample.insert().save()
Bulk Insert or Update
insert_or_update()If the primary key or unique key already exists, it will be updated, and if it does not exist, it will be inserted.
sample = multy.BulkQuery(con, 'sample')
for i in range(10):
sample.add_record({
'id': 1,
'age': 28,
'name': 'test'
})
sample.insert_or_update().save()
If you have Django
from django.db import connectionIf you are using mysqlclient or pymysql with Django, you can use the imported connection as is
from django.db import connection
import multy
sample = multy.BulkQuery(connection, 'sample')
License
multy is under MIT license.
Metadata
Release files for multy 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| multy-1.0.1.tar.gz | 3.0 kB | Without provenance | Details for multy-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| multy-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for multy-1.0.1-py3-none-any.whl |
Total release size: 7.1 kB
Release files / multy-1.0.1.tar.gz
| Download URL | multy-1.0.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce8f20e37f7443bd49a146653d16bc238ee5de3bb38eafb25140f1a284710ac4
|
|
BLAKE2b-256 checksum How to use checksums |
6fe8758e5d18a033288ab210ba57744d18373a693ae7528b31b99f32ccc89f66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Release files / multy-1.0.1-py3-none-any.whl
| Download URL | multy-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49ec3d35d73c9c0054459d525c8fe7702f6976b81ec6d81723698b15bf5f1596
|
|
BLAKE2b-256 checksum How to use checksums |
640e58070bd52c01070a4390523febabfbbf16c211c3bf6f574412f83626c921
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Security for multy 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.