Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #
- import sqlite3
- con = sqlite3.connect("/home/azureuser/clever/clever.db")
- cur = con.cursor()
- sql = '''
- BEGIN TRANSACTION;
- CREATE TABLE Config (
- var TEXT primary key,
- value TEXT);
- INSERT INTO Config VALUES('email','');
- INSERT INTO Config VALUES('secretCode','');
- INSERT INTO Config VALUES('userSecret','');
- INSERT INTO Config VALUES('dayCode','');
- INSERT INTO Config VALUES('connectorId','');
- INSERT INTO Config VALUES('chargeBoxId','');
- INSERT INTO Config VALUES('lastHistoryDL','');
- INSERT INTO Config VALUES('lastCodeRenew','');
- CREATE TABLE CleverHistory (
- chargePointId TEXT,
- connectorId INT,
- transactionId INT,
- idTag TEXT,
- startTimeLocal INT,
- stopTimeLocal INT,
- startTimeUtc INT,
- stopTimeUtc INT,
- kWh REAL,
- idTokenSubscriptionLineId TEXT
- );
- CREATE TABLE CleverCharging(
- status TEXT,
- timestamp TEXT,
- transactionId INT,
- consumedWh REAL,
- started TEXT,
- cardNumber TEXT,
- latestConsumptionWh REAL
- );
- CREATE UNIQUE INDEX CleverHistoryStartTimeUTCUnique on CleverHistory(startTimeUtc);
- CREATE UNIQUE INDEX CleverHistoryUnique on CleverHistory(startTimeUtc,stopTimeUtc);
- CREATE INDEX CleverHistoryTransaction on CleverHistory(transactionId);
- CREATE INDEX CleverHistoryStartTimeLocal on CleverHistory(startTimeLocal);
- CREATE INDEX CleverHistoryStopTimeUTC on CleverHistory(stopTimeUtc);
- CREATE INDEX CleverHistoryStopTimeLocal on CleverHistory(stopTimeLocal);
- CREATE UNIQUE INDEX CleverChargingUnique on CleverCharging(timestamp,started,transactionId,consumedWh);
- CREATE INDEX CleverChargingTransaction on CleverCharging(transactionId);
- CREATE INDEX CleverChargingTimeStamp on CleverCharging(timestamp);
- CREATE INDEX CleverChargingStarted on CleverCharging(started,timestamp);
- COMMIT;
- '''
- for x in sql.split(";"):
- cur.execute(x+";")
- con.commit()
- con.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement