-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql.h
26 lines (20 loc) · 911 Bytes
/
sql.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef SQL_INCLUDED
#define SQL_INCLUDED 1
#include <iostream>
#include <string>
#include <sqlite3.h>
#define SQL_CHECK(code, expected) \
do { \
int sql_check_code = (code); \
if (sql_check_code != (expected)) { \
std::cerr << "Sqlite3 fail: " __FILE__ ":" \
<< __LINE__ << ": " \
<< sql_check_code << std::endl; \
std::exit(1); \
} \
} while (0)
#define SQL_OK(code) SQL_CHECK(code, SQLITE_OK)
extern int
open_sql_db_and_ensure_close_on_exit(const char *filename,
sqlite3 **db);
#endif // SQL_INCLUDED