| 226 | }; |
| 227 | |
| 228 | int 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))) |
nothing calls this directly
no test coverage detected
searching dependent graphs…