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