██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██╗ ██╗
██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝██║ ██║
██║ ██║██████╔╝██████╔╝██║ ██║███████╗███████║
██║ ██║██╔══██╗██╔═══╝ ██║ ██║╚════██║██╔══██║
██████╔╝██████╔╝██║ ╚██████╔╝███████║██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
Import .csv and .xlsx files directly into PostgreSQL and MySQL
— from your terminal or Python code.
What is DBSHEET?
DBSHEET is a zero-boilerplate CLI and Python utility that turns spreadsheet files into live database tables. No schema writing. No manual column mapping. No encoding headaches.
Point it at a file. Configure the database. Done. how to use cli tool
python -m dbpush.cli
The Old Way vs DBSHEET
| Without DBSHEET | With DBSHEET |
|---|---|
| Open spreadsheet | pip install dbpush==1.0.0 |
| Write a custom parser | dbpush (or 3 lines of Python) |
| Map columns manually | ✅ Auto schema from headers |
| Write SQL CREATE TABLE | ✅ Table created automatically |
| Write INSERT loops | ✅ Rows inserted + upserted |
| Debug encoding issues | ✅ Just works |
Features
✦ CSV import ✦ Excel (.xlsx) import
✦ PostgreSQL support ✦ MySQL support
✦ Auto table creation ✦ Header-based schema generation
✦ Upsert on duplicate keys ✦ Interactive CLI
✦ Python API ✦ Config file support
Installation
pip install dbpush
Quick Start
Config File
Create a config.txt file:
db_type:postgres
host:localhost
port:5432
user:postgres
password:secret
database:mydb
file_name:./data.csv
sheet_name:Sheet1
CLI
Launch the interactive terminal:
dbsheet
Typical workflow:
config_file # load your config
connect # connect to the database
create_table # create table from spreadsheet headers
insert # insert all rows
select # view the data
Python API
from dbpush.dbpush import dbpush
db = dbpush.create(
db_type="postgres",
host="localhost",
user="postgres",
password="secret",
database="mydb",
port=5432,
file_name="./data.csv"
)
db.connect()
db.create_table()
db.insert()
db.select_all()
Supported Formats
| File Type | Supported |
|---|---|
.csv |
✅ Yes |
.xlsx |
✅ Yes |
Supported Databases
| Database | Supported |
|---|---|
| PostgreSQL | ✅ Yes |
| MySQL | ✅ Yes |
Example Input
CSV:
id,name,age,salary
1,ram,22,50000
2,radha,25,70000
DBSHEET will:
- Create a table named
data - Map each header to a column (
id→ primary key, rest → text) - Insert all rows automatically
- Upsert if a row with the same primary key already exists
CLI Commands
| Command | Description |
|---|---|
config |
Configure database connection manually |
config_file |
Load configuration from a file |
connect |
Connect to the database |
create_db |
Create the database if it doesn't exist |
create_table |
Create a table from the spreadsheet headers |
insert |
Insert (or upsert) all rows from the file |
select |
Display all rows from the table |
truncate |
Remove all rows from the table (keep structure) |
drop_table |
Permanently delete the table |
row_count |
Print the number of rows in the spreadsheet |
col_count |
Print the number of columns in the spreadsheet |
header |
Display column names from the spreadsheet |
sheet |
Display the active sheet name |
find |
Search for a row by column value |
Python API Reference
dbpush.create(...)
Factory method to create a new Dbsheet instance.
db = dbpush.create(
db_type="postgres", # "postgres" or "mysql"
host="localhost",
user="postgres",
password="secret",
database="mydb",
port=5432,
file_name="./data.csv",
sheet_name="Sheet1" # optional, for .xlsx files
)
create_db()
Creates the database if it does not already exist.
db.create_db()
connect()
Establishes a connection to the database and prepares the cursor.
db.connect()
create_table()
Reads the spreadsheet headers and creates a matching SQL table.
- The
idcolumn is set as the primary key - All other columns are created as text fields
db.create_table()
insert()
Reads all rows from the spreadsheet and inserts them into the table.
Handles duplicate primary keys via upsert — existing rows are updated, new rows are inserted.
db.insert()
select_all()
Prints all rows currently in the table.
db.select_all()
drop_table()
Permanently deletes the table from the database.
db.drop_table()
truncate_table()
Removes all rows from the table while keeping the table structure intact.
db.truncate_table()
row_count()
Prints the total number of data rows in the spreadsheet (excluding the header).
db.row_count()
col_count()
Prints the total number of columns in the spreadsheet.
db.col_count()
show_header()
Prints the list of column names from the spreadsheet header row.
db.show_header()
show_sheet()
Prints the name of the active sheet (relevant for .xlsx files).
db.show_sheet()
find(column, value)
Searches through the spreadsheet rows and returns rows where column matches value.
db.find("name", "ram")
# Returns all rows where the "name" column equals "ram"
Full Examples
PostgreSQL
from dbpush.dbpush import dbpush
db = dbpush.create(
db_type="postgres",
host="localhost",
user="postgres",
password="secret",
database="mydb",
port=5432,
file_name="./data.csv"
)
db.connect()
db.create_table()
db.insert()
db.select_all()
MySQL
from dbpush.dbpush import dbpush
db = dbpush.create(
db_type="mysql",
host="localhost",
user="root",
password="secret",
database="mydb",
port=3306,
file_name="./data.xlsx",
sheet_name="Sheet1"
)
db.connect()
db.create_table()
db.insert()
db.select_all()
Use Cases
- 🌱 Seeding development and staging databases
- 🛠 Internal admin tools and dashboards
- ⚡ Rapid prototyping with real data
- 📦 Importing spreadsheets from clients
- 🔄 Lightweight ETL pipelines
- 📊 Data migration scripts
Project Structure
dbsheet-public/
├── README.md
├── examples/
│ ├── postgres_example.py
│ └── mysql_example.py
├── screenshots/
│ ├── cli.png
│ └── demo.gif
└── roadmap.md
Roadmap
- Better type inference (int, float, date detection)
- Connection URI support (
postgresql://user:pass@host/db) - Batch folder import (import entire directory of files)
- Improved error messages and validation
- Export database table → CSV
- SQLite support
See roadmap.md for full details.
License
MIT © Sarthak sachdeva
If dbpush saved you time, a ⭐ on the repo means a lot.
Built with ♥ by Sarthak sachdeva
Metadata
Release files for dbpush 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 |
|---|---|---|---|---|
| dbpush-1.0.1.tar.gz | 14.8 kB | Without provenance | Details for dbpush-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dbpush-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for dbpush-1.0.1-py3-none-any.whl |
Total release size: 27.1 kB
Release files / dbpush-1.0.1.tar.gz
| Download URL | dbpush-1.0.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b60491d99bee06b64d6ab0d5a6d0247d064fd0597415d9afc276ff6944831068
|
|
BLAKE2b-256 checksum How to use checksums |
2833cf52ee621ba4953e0796c5eab6e39c36c9d8222819ab2b07e1c782613bf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / dbpush-1.0.1-py3-none-any.whl
| Download URL | dbpush-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33e49bdb8e15199b0addced873d0b08b7d45b41207fa9f0b32d355f4c235542a
|
|
BLAKE2b-256 checksum How to use checksums |
eda529f2631e3c399dc368a2bb8ba7c5e4dac115b57186b3290a266e0d1e0e68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for dbpush 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.