Skip to main content

tablemaster is a Python toolkit for moving and managing tabular data across databases, Feishu/Lark, Google Sheets, and local files with one consistent API.

Project description

tablemaster

tablemaster is a Python toolkit for moving and managing tabular data across databases, Feishu/Lark, Google Sheets, and local files with one consistent API.

Why tablemaster

  • Unified DataFrame-first API across multiple data backends
  • Production-friendly DB helpers (query, execute, chunked upload, upsert)
  • Built-in Feishu and Google Sheets connectors
  • Local CSV/Excel ingestion utilities
  • Declarative two-way sync between Feishu Sheet and database table
  • Configuration-first design for reproducible automation

Installation

Install core package:

pip install -U tablemaster

Install backend-specific extras as needed:

pip install -U "tablemaster[mysql]"    # MySQL/TiDB database support
pip install -U "tablemaster[feishu]"   # Feishu/Lark connectors
pip install -U "tablemaster[gspread]"  # Google Sheets connectors
pip install -U "tablemaster[local]"    # Local CSV/Excel helpers
pip install -U "tablemaster[all]"      # Everything above

Configuration

Load configuration with:

import tablemaster as tm

cfg = tm.load_cfg()

Load config from another path:

import os
import tablemaster as tm

cfg = tm.load_cfg(path="C:/configs/tablemaster/prod.yaml")
cfg = tm.load_cfg(path="C:/configs/tablemaster")

os.environ["TM_CFG_PATH"] = "D:/ops/tablemaster/cfg.yaml"
cfg = tm.load_cfg()

load_cfg() resolves config file in this order:

  1. Explicit path argument
  2. TM_CFG_PATH environment variable
  3. ./cfg.yaml
  4. ~/.tablemaster/cfg.yaml

Example cfg.yaml:

mydb:
  host: 10.0.0.1
  user: admin
  password: secret
  database: bake_prod
  port: 3306
  db_type: mysql

db_tidb:
  host: sh.internal
  user: reader
  password: xxx
  database: analytics
  db_type: tidb
  use_ssl: true
  ssl_ca: /path/to/ca.pem

feishu_prod:
  feishu_app_id: cli_xxx
  feishu_app_secret: yyy

gsheet:
  service_account_path: /absolute/path/to/service_account.json

For Google Sheets authentication setup, see: https://docs.gspread.org/en/latest/oauth2.html

Quick Start

Query and execute SQL

import tablemaster as tm

cfg = tm.load_cfg()
df = tm.query("SELECT * FROM orders LIMIT 20", cfg.mydb)
tm.opt("ALTER TABLE orders RENAME COLUMN old_col TO new_col", cfg.mydb)

Manage database tables

import tablemaster as tm

cfg = tm.load_cfg()
tb = tm.ManageTable("orders", cfg.mydb)
tb.upload_data(df, add_date=True)
tb.upsert_data(df, key="order_id")
tb.par_del("order_date > '2023-01-01'")

Google Sheets

import tablemaster as tm

cfg = tm.load_cfg()
sheet = ("spreadsheet_id_or_name", "worksheet_name")
df = tm.gs_read_df(sheet, cfg.gsheet)
tm.gs_write_df(sheet, df, cfg.gsheet)

Feishu / Lark

import tablemaster as tm

cfg = tm.load_cfg()
feishu_sheet = ("spreadsheet_token", "sheet_id")
feishu_base = ("app_token", "table_id")

sheet_df = tm.fs_read_df(feishu_sheet, cfg.feishu_prod)
base_df = tm.fs_read_base(feishu_base, cfg.feishu_prod)
tm.fs_write_df(feishu_sheet, sheet_df, cfg.feishu_prod, loc="A1", clear_sheet=False)
tm.fs_write_base(feishu_base, base_df, cfg.feishu_prod, clear_table=False)

Local files

import tablemaster as tm

single_df = tm.read("*orders_2026*")
merged_df = tm.batch_read("*orders_2026*")
df_list = tm.read_dfs("*orders_2026*")

Declarative two-way sync

import tablemaster as tm

cfg = tm.load_cfg()
feishu_sheet = ("spreadsheet_token", "sheet_id")

merged = tm.sync(
    source=("feishu", feishu_sheet, cfg.feishu_prod),
    target=("db", cfg.mydb, "orders"),
    on_conflict="upsert",
    key="order_id",
)

CLI

tablemaster now ships with a built-in CLI:

tablemaster --help
python -m tablemaster --help

Commands:

tablemaster version-info
tablemaster config list --cfg-path ./cfg.yaml
tablemaster config show mydb --cfg-path ./cfg.yaml
tablemaster db query "SELECT * FROM orders LIMIT 20" --cfg-key mydb --cfg-path ./cfg.yaml
tablemaster db query "SELECT * FROM orders" --cfg-key mydb --output ./out/orders.csv
tablemaster local read "*orders_2026*" --limit 10
tablemaster local read "*orders_2026*" --no-det-header

CLI command groups:

  • version-info: Print installed package version.

  • config show <cfg_key>: Print one config entry as JSON.
  • db query <sql>: Run SQL with --cfg-key; use --limit to control stdout preview and --output to export full result as CSV.
  • local read <pattern>: Read one local CSV/Excel match and print preview; use --det-header/--no-det-header to control header detection.
  • config list: List top-level keys from config.

--cfg-path accepts either a config file path or a directory containing cfg.yaml.

Public API

  • Database: query, opt, ManageTable
  • Feishu/Lark: fs_read_df, fs_write_df, fs_read_base, fs_write_base
  • Google Sheets: gs_read_df, gs_write_df
  • Local files: read, batch_read, read_dfs
  • Sync: sync
  • Config: load_cfg

Notes

  • Python 3.9+ is required.
  • CLI entrypoint is tablemaster; use tablemaster --help for command details.
  • tm.cfg and read_cfg() are backward-compatible but deprecated in favor of load_cfg().
  • PostgreSQL upsert is supported by code path; install PostgreSQL driver dependencies separately when needed.

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

tablemaster-2.0.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

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

tablemaster-2.0.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file tablemaster-2.0.0.tar.gz.

File metadata

  • Download URL: tablemaster-2.0.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tablemaster-2.0.0.tar.gz
Algorithm Hash digest
SHA256 04642a279b9bab7c2f6352322de681500f3c98f3d8601bb19539fdedd6773a1a
MD5 aad539c0fb2bffd1d3b2d7d0116f2cd4
BLAKE2b-256 2eeba4ec09d3f9e835f1a1d4e10ec1fa7e6d154b2740cc36d55468bd996b0a98

See more details on using hashes here.

File details

Details for the file tablemaster-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: tablemaster-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tablemaster-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97ccb8640f9b1890aa1093b10697bb4787f163d24dacad3b40dd147fb7a6ec81
MD5 5b29df3cf629c54e05f0ea4a0bc7a09b
BLAKE2b-256 9adf6cc2bad4a25c76790548cc94c3eb778dc99223ecdc101b85db576c37b26b

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