██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██╗ ██╗
██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝██║ ██║
██║ ██║██████╔╝██████╔╝██║ ██║███████╗███████║
██║ ██║██╔══██╗██╔═══╝ ██║ ██║╚════██║██╔══██║
██████╔╝██████╔╝██║ ╚██████╔╝███████║██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
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.
| 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 |
✦ 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
pip install dbpushCreate a config.txt file:
db_type:postgres
host:localhost
port:5432
user:postgres
password:secret
database:mydb
file_name:./data.csv
sheet_name:Sheet1db_type:mysql
host:localhost
port:3306
user:root
password:secret
database:mydb
file_name:./data.csv
sheet_name:Sheet1Launch the interactive terminal:
dbsheetTypical 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 datafrom 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()| File Type | Supported |
|---|---|
.csv |
✅ Yes |
.xlsx |
✅ Yes |
| Database | Supported |
|---|---|
| PostgreSQL | ✅ Yes |
| MySQL | ✅ Yes |
CSV:
id,name,age,salary
1,ram,22,50000
2,radha,25,70000DBSHEET 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
| 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 |
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
)Creates the database if it does not already exist.
db.create_db()Establishes a connection to the database and prepares the cursor.
db.connect()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()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()Prints all rows currently in the table.
db.select_all()Permanently deletes the table from the database.
db.drop_table()Removes all rows from the table while keeping the table structure intact.
db.truncate_table()Prints the total number of data rows in the spreadsheet (excluding the header).
db.row_count()Prints the total number of columns in the spreadsheet.
db.col_count()Prints the list of column names from the spreadsheet header row.
db.show_header()Prints the name of the active sheet (relevant for .xlsx files).
db.show_sheet()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"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()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()- 🌱 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
dbsheet-public/
├── README.md
├── examples/
│ ├── postgres_example.py
│ └── mysql_example.py
├── screenshots/
│ ├── cli.png
│ └── demo.gif
└── roadmap.md
- 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.
MIT © Sarthak sachdeva
If dbpush saved you time, a ⭐ on the repo means a lot.
Built with ♥ by Sarthak sachdeva



