AS a beginner on Python and SQLlite I am wandering if there are more elegant solutions for the tasks I have.
My current SQLLite database contains several time series as:
CREATE TABLE Y1 (time REAL, value REAL);
CREATE TABLE Y2 (time REAL, value REAL);
CREATE TABLE Y3 (time REAL, value REAL);
...
The time values are not identical for all variables, however there might be dublicates.
However, since the list of the variables is increasing, I want to transfer the data to a sturcture like. The Table 'VARLIST' should collect all variables.
CREATE TABLE VARLIST (VarID INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL);
INSERT INTO VARLIST VALUES(1, 'Y1');
INSERT INTO VARLIST VALUES(2, 'Y2');
...
The datapoints itself shall be transfered to the Tables, TIMESTAMPS
and DATAPOINTS
. The timestamps are in an sperate tabele since I want to associate additional information to this stamps (not shown in this siplified example).
CREATE TABLE TIMESTAMPS (timeID INTEGER PRIMARY KEY, time REAL);
CREATE TABLE DATAPOINTS (DataID INTEGER PRIMARY KEY, timeID INTEGER, VarID INTEGER, value REAL);
My question is: How can I best transfer the data from the tables Y1
.. Y6
in the Tables TIMESTAMPS
and DATAPOINTS
? Of course I can read out all the data to Python and let Python do the regrouping. Anyhow I want to know if this would be possible also by using only SQLLite commands.
Aucun commentaire:
Enregistrer un commentaire