Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
791 | werner | 1 | ### SQL helping function |
2 | |||
3 | # we use the R library RSQLite for all database accesses |
||
4 | # look up the help for the avaiable features. |
||
5 | library(RSQLite) |
||
6 | |||
7 | db.conn <- NA |
||
8 | query<-function(query_str) { |
||
9 | res <- dbSendQuery(db.conn, query_str) |
||
10 | data <- fetch(res, n=-1) |
||
11 | if (dbGetException(db.conn)$errorNum>0) |
||
12 | print(dbGetException(db.conn)$errorMsg) |
||
13 | dbClearResult(res) |
||
14 | data |
||
15 | } |
||
16 | |||
17 | ## species colors |
||
18 | # species_colors<-c("red", "blue", "green", "gray") |
||
19 | # names(species_colors)<-c("piab","fasy","lade", "pisy") |
||
20 | # species.color <- function(species) { |
||
21 | # if (species %in% names(species_colors)) { |
||
22 | # return (species_colors[species]); |
||
23 | # } else { |
||
24 | # return ("black"); |
||
25 | # } |
||
26 | # } |
||
27 | |||
28 | ### query all tables from the output database |
||
29 | query("SELECT name FROM sqlite_master WHERE type='table'"); # use select * for more details! |