Completing the data lifecycle is often harder than originally expected: Deleting data can cost sometimes way more than inserting it in the first place. MySQL Partitions can offer a way out. We have an earlier post on the subject.
A sample table, and a problem statement
Let’s define a kind of log table, to which data is added with an
auto_increment id value and some data.
#! /usr/bin/env python3
from time import sleep
from random import randint
from multiprocessing import Process
import click
import MySQLdb
import MySQLdb.cursors
db_config = dict(
host="localhost",
user="kris",
passwd="geheim",
db="kris",
cursorclass=MySQLdb.cursors.DictCursor,
)
@click.group(help="Load and delete data using partitions")
def sql():
pass
@sql.command()
def setup_tables():
sql_setup = [
"drop table …[Read more]