2.用数据结构来进行insert
| TEST(soci,insert_obj_noexist) { try { session sql(mysql, "db=soci user=dantezhu"); Person p = { 0, "niuniu", 2 }; sql << "insert into tb_test(name, sex) values(:name, :sex)", use(p); } catch (exception const &e) { FAIL()<<e.what(); } } TEST(soci,insert_obj_noexist) { try { session sql(mysql, "db=soci user=dantezhu"); Person p = { 0, "niuniu", 2 }; sql << "insert into tb_test(name, sex) values(:name, :sex)", use(p); } catch (exception const &e) { FAIL()<<e.what(); } } |
整个就是这样~~下面是文中代码文件的下载路径:
http://code.google.com/p/vimercode/source/browse/#svn%2Ftrunk%2Fsoci_test
另外,虽然python下的mysql访问也算比较简单,但还是想知道是否有更Pythonic的库或接口,如果有朋友知道,欢迎不吝告知。










