MCPcopy Create free account
hub / github.com/davisking/dlib / table_exists

Function table_exists

examples/sqlite_ex.cpp:17–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15// ----------------------------------------------------------------------------------------
16
17bool table_exists (
18 database& db,
19 const std::string& tablename
20)
21{
22 // Sometimes you want to just run a query that returns one thing. In this case, we
23 // want to see how many tables are in our database with the given tablename. The only
24 // possible outcomes are 1 or 0 and we can do this by looking in the special
25 // sqlite_master table that records such database metadata. For these kinds of "one
26 // result" queries we can use the query_int() method which executes a SQL statement
27 // against a database and returns the result as an int.
28 return query_int(db, "select count(*) from sqlite_master where name = '"+tablename+"'")==1;
29}
30
31// ----------------------------------------------------------------------------------------
32

Callers 1

mainFunction · 0.85

Calls 1

query_intFunction · 0.85

Tested by

no test coverage detected