Sqlite3 get primary key and table name?

I need a way to get the primary key and the table name from a returned result.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  if (sqlite3_prepare_v2(db, query, -1, &stmt, 0) == SQLITE_OK)
    {
        rs = new Records();
        int cols = sqlite3_column_count(stmt);
        int result;
        do
        {
            result = sqlite3_step(stmt);
            if (result == SQLITE_ROW)
            {
                r = new Record();
                for (int i = 0; i < cols; i++)
                {
                    c = new Column();
                    c->colName = sqlite3_column_name(stmt, i);
                    c->data.datai = sqlite3_column_int(stmt, i);
                    c->data.datal = sqlite3_column_int64(stmt, i);
                    dataP = sqlite3_column_text(stmt, i);
                    memcpy((void*)c->data.datac, (void*) dataP, 512);
                    r->columns.push_back(c);
                }
                rs->record.push_back(r);
            }
        } while(result == SQLITE_ROW);


How would I get the current primary key and table name automatically?

I need to know this because I want to implement a delete method into my database wrapper so people can just do record->delete(); nice and easy no query involved.

Thanks
Last edited on
Topic archived. No new replies allowed.