Skip to main content

lazyins

A stupid database insert helper

This tool makes MySQL/SQLite table with the values, then insert the values.

Install

python -m pip install lazyins

Usage

Set environment variables to connect your mysql database.

export LAZYINS_HOST="localhost"
export LAZYINS_PORT=3306
export LAZYINS_USER="root"
export LAZYINS_PASSWD="password"

You don't need this setting for SQLite database.

Then make cursor.

from lazyins import Cursor
cur = Cursor()  # default : mysql
# cur = Cursor(db='sqlite', db_name='your_db.db', table_name='your_table')  # sqlite option

This Cursor() function also recieves db, host, port, user, passwd, db_name, and table_name as arguments.

Case 1

If you have two list to insert database.

names = ['value1', 'value2', 'value3']
values = [1, 2, 3.3]

You can make table and insert with cur.register(values, names). The column types will be assumed.

Case 2

You have a list of tuple like that.

data = [('value1', 1), ('value2', 2), ('value3', 3.3)]

This simple cur.register(data) works.

Case 3

If you want to let it assume almost all values, but you want set explicit types for some values. For example, you need to set tinyint instead of int (assumed) for value2,

explicit_types = [('values', 'tinyint')]
cur.register(values, names, explicit_types=explicit_types)

Detail options

For string, default length is 40. If you need more, cur.default_char_length = 100.

Release files for lazyins 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lazyins 0.1.1
File Size Uploaded
lazyins-0.1.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lazyins 0.1.1
File Interpreter ABI Platform
lazyins-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / lazyins-0.1.1.tar.gz

Download URL lazyins-0.1.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8b0e6c790d14f1811dc467775a489aec682127566b311406eafc3b542bb12e74
BLAKE2b-256 checksum
How to use checksums
5ecd0f50c99990b6b0e21f001bc977dfa54264f266baabea8b73b85c9c0f3889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / lazyins-0.1.1-py3-none-any.whl

Download URL lazyins-0.1.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ecc90200ab6c07b18117b9d33769f5df9097937ef6226a3636a4b067e216ed6
BLAKE2b-256 checksum
How to use checksums
dacd5b2df5a2ba5efa31056bb8a8abd05a9346d54d0df36bf158bf4e0cfa0f3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page