Sqlite3 "chained" query
Posted
by Arrieta
on Stack Overflow
See other posts from Stack Overflow
or by Arrieta
Published on 2009-12-12T03:00:26Z
Indexed on
2010/05/30
3:02 UTC
Read the original article
Hit count: 425
I need to create a configuration file from a data file that looks as follows:
MAN1_TIME '01-JAN-2010 00:00:00.0000 UTC'
MAN1_RX 123.45
MAN1_RY 123.45
MAN1_RZ 123.45
MAN1_NEXT 'MAN2'
MAN2_TIME '01-MAR-2010 00:00:00.0000 UTC'
MAN2_RX 123.45
[...]
MAN2_NEXT 'MANX'
[...]
MANX_TIME [...]
This file describes different "legs" of a trajectory. In this case, MAN1
is chained to MAN2
, and MAN2
to MANX
. In the original file, the chains are not as obvious (i.e., they are non-sequential).
I've managed to read the file and store in an Sqlite3 database (I'm using the Python interface). The table is stored with three columns: Id
, Par
, and Val
; for instance, Id='MAN1'
, Par='RX'
, and Val='123.45'
.
I'm interested in querying such database for obtaining the information related to 'n' legs. In English, that would be:
"Select RX,RY,RZ for the next five legs starting on MAN1"
So the query would go to MAN1
, retrieve RX
, RY
, RZ
, then read the parameter NEXT
and go to that Id
, retrieve RX
, RY
, RZ
; read the parameter NEXT
; go to that one ... like this five times.
How can I pass such query with "dynamic parameters"?
Thank you.
© Stack Overflow or respective owner