File: ls_tables.c

package info (click to toggle)
apophenia 0.999b%2Bds3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,892 kB
  • ctags: 1,840
  • sloc: ansic: 20,530; makefile: 346; sh: 230; awk: 135; sed: 26
file content (18 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <apop.h>

void print_table_list(char *db_file){
    apop_db_open(db_file);
    apop_data *tab_list= apop_query_to_text("select name "
                    "from sqlite_master where type=='table'");
    for(int i=0; i< tab_list->textsize[0]; i++)
        printf("%s\n", tab_list->text[i][0]);
}

int main(int argc, char **argv){
    if (argc == 1){
        printf("Give me a database name, and I will print out "
               "the list of tables contained therein.\n");
        return 0; 
    }
    print_table_list(argv[1]);
}