Initial commit: CSV to SQLite CLI tool
CLI tool to import EDF electricity meter readings from CSV files into a SQLite database. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
38
CLAUDE.md
Normal file
38
CLAUDE.md
Normal file
@@ -0,0 +1,38 @@
|
||||
this project is a tool CLI that can take CSV file and push its content into a sqlite database.
|
||||
|
||||
the CSV files have the following columns:
|
||||
|
||||
- Date de relevé de l'index
|
||||
- Type d'index
|
||||
- Index Heures pleines (kWh)
|
||||
- Index Heures creuses (kWh)
|
||||
|
||||
the sqlite database has been created with the following command:
|
||||
|
||||
CREATE TABLE "electricite" (
|
||||
"date" TEXT NOT NULL UNIQUE,
|
||||
"releveHC" INTEGER NOT NULL,
|
||||
"releveHP" INTEGER NOT NULL,
|
||||
"comment" TEXT,
|
||||
PRIMARY KEY("date")
|
||||
)
|
||||
|
||||
CSV column "Date de relevé de l'index" has to be mapped with database column "date"
|
||||
CSV column "Index Heures pleines (kWh)" has to be mapped with database column "releveHP"
|
||||
CSV column "Index Heures creuses (kWh)" has to be mapped with database column "releveHC"
|
||||
|
||||
the CLI takes 2 parameters:
|
||||
|
||||
- first is the name of the CSV file
|
||||
- second is the JDBC URL (for example, "jdbc:sqlite:/Users/kriss/NextCloud/Kriss/Dev/Perso/conso/db/conso.db")
|
||||
|
||||
when launched, the tool checks that:
|
||||
|
||||
- CSV file exists on the disk
|
||||
- CSV file contains exactly the described columns
|
||||
- Sqlite database is accessible through the JDBC URL
|
||||
- Ensure there won't be any duplicates inserted in the database (which means if the tool is launched twice in a row, no new lines will be inserted)
|
||||
- Tell the user how many new lines are going to be inserted in the database, and ask his agreement before proceeding
|
||||
- Performs the insert in the database
|
||||
|
||||
this project is written in Rust.
|
||||
Reference in New Issue
Block a user