MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/sqlite/sqlite.cpp:228–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226};
227
228int main(void)
229{
230 acl::acl_cpp_init();
231 acl::log::stdout_open(true);
232
233 acl::stdin_stream in;
234 acl::stdout_stream out;
235 acl::string line;
236
237#if defined(_WIN32) || defined(_WIN64)
238 const char* libname = "sqlite3.dll";
239#else
240 const char* libname = "libsqlite3.so";
241#endif
242
243 acl::string path;
244 out.format("Enter %s load path: ", libname);
245 if (in.gets(line) && !line.empty())
246#if defined(_WIN32) || defined(_WIN64)
247 path.format("%s\\%s", line.c_str(), libname);
248#else
249 path.format("%s/%s", line.c_str(), libname);
250#endif
251 else
252 path = libname;
253
254 out.format("%s path: %s\r\n", libname, path.c_str());
255 // ���ö�̬����ص�ȫ·��
256 acl::db_handle::set_loadpath(path);
257
258 //acl::string dbfile("�������ݿ�.db");
259 acl::string dbfile("./path1/path2/mydb.db");
260
261 // db_sqlite �������������� set_loadpath ֮����Ϊ�� db_sqlite ��
262 // ���캯������Ҫ���м��� libsqlite3.so
263 acl::db_sqlite db(dbfile, "gbk");
264
265 if (db.open() == false)
266 {
267 printf("open dbfile: %s error\r\n", dbfile.c_str());
268 getchar();
269 return 1;
270 }
271
272 printf("open dbfile %s ok\r\n", dbfile.c_str());
273
274 if (tbl_create(db) == false)
275 {
276 printf("create table error\r\n");
277 getchar();
278 return 1;
279 }
280
281 // �������ݿ�����
282 db.set_conf("PRAGMA synchronous = off");
283 db.set_conf("PRAGMA encoding = \"UTF-8\"");
284 acl::string buf;
285 if ((db.get_conf("PRAGMA encoding", buf)))

Callers

nothing calls this directly

Calls 15

acl_cpp_initFunction · 0.85
meter_timeFunction · 0.85
getsMethod · 0.80
get_confMethod · 0.80
show_confMethod · 0.80
beginMethod · 0.80
tbl_createFunction · 0.70
formatMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
openMethod · 0.45
set_confMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…