Skip to main content

logo MySqlSaver

Effortlessly save your pandas DataFrames into MySQL with automatic table creation and support for primary keys and partitioning.

GitHub


Installation

pip install mysqlsaver

Connection

Create a connection to your MySQL database:

from mysqlSaver import Connection

conn = Connection.connect(
    host="your_host",
    port="your_port",
    username="your_username",
    password="your_password",
    database="your_database"
)

Keys Manager

from mysqlSaver import KeyManager

key_mgr = KeyManager(conn)


key_mgr.add_primary_key('my_table', ['id'])

key_mgr.drop_primary_key('my_table')


key_mgr.add_unique_key('my_table', ['email' , 'name'])

key_mgr.drop_unique_key('my_table', 'unique_email_name')
  • Create the primarykey or unique fields
  • Drop the primarykey or unique fields

Save a DataFrame

from mysqlSaver import Saver
import pandas as pd

df = pd.DataFrame({...})
saver = Saver(conn)
saver.sql_saver(df, "table_name")

This function:

  • Creates the table if it does not exist
  • Inserts the DataFrame data

Save with Primary Key

saver.sql_saver_with_primarykey(df, "table_name", primary_key_list=["id"])

Save with Primary Key and Auto-Update

saver.sql_saver_with_primarykey_and_update(df, "table_name", primary_key_list=["id"])

This performs UPSERT using the primary key.

Save with Unique Key (No Duplicate Insertions)

saver.sql_saver_with_unique_key(df, "table_name")

Update Table Based on Primary Key

saver.sql_updater_with_primarykey(df, "table_name", primary_key_list=["id"])

Checker and Reader

from mysqlSaver import CheckerAndReceiver

checker = CheckerAndReceiver(conn)
exists = checker.table_exist("table_name")
df = checker.read_table("table_name")

Table and Database Creation

from mysqlSaver import Creator

creator = Creator(conn)
creator.database_creator("new_database")
creator.create_table(df, "new_table")

Partitioning Tables

from mysqlSaver import Partition

partitioner = Partition(conn)
partitioner.create_partition_table(
    df,
    "partitioned_table",
    range_key="your_date_column",
    primary_key_list=["id"],
    start_year_partition=2020,
    end_year_partition=2025
)

Metadata

Release files for mysqlSaver 0.2.7

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

Source distribution (sdist)

Source distribution for mysqlSaver 0.2.7
File Size Uploaded Provenance Actions
mysqlSaver-0.2.7.tar.gz 5.7 kB Without provenance Details for mysqlSaver-0.2.7.tar.gz

Release files / mysqlSaver-0.2.7.tar.gz

Download URL mysqlSaver-0.2.7.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a7f7f45756a3b6e601de29e5c4644c86b173551def525f1cc7f08dc1b7140149
BLAKE2b-256 checksum
How to use checksums
7dd647a2c9d58386be2208e5d975cbbc2599b144c309ec6998f10e8632db45a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Security for mysqlSaver 0.2.7

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.

Release history Release notifications | RSS feed

This release

0.2.7 This release

1 release file No provenance

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