C++的數據庫持久層框架 LiteSQL
LiteSQL 是一個C++的數據庫持久層框架,支持 SQLite3、MySQL和PostgreSQL數據庫。
- SQLite3, PostgreSQL, MySQL and Oracle-backend support
- C++ object persistence (store, update, retrieve)
- relational operations (filtering, ordering, referencing other objects)
- automatic database structure maintenance (creates, updates and drops tables/indices behind the scenes)
- C++ template based database API -> no SQL queries by hand
示例代碼:
<?xml version="1.0"?> <!DOCTYPE database SYSTEM "litesql.dtd"> <database name="PersonDatabase"> <object name="Person"> <field name="name" type="string"/> </object> </database>
PersonDatabase db("sqlite3", "database=person.db");Person person(db); // construct Person, does not write anything to database person.name = "Bob"; // assign values to fields person.age = 20; person.update(); // writes a new record to database person.age = 21; // Bob got just older person.update(); // updates old record person.id = 100; // force internal identifier (id) to 100 person.update(); // updates old record
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!