Skip to content

denisbilli/qDBManager

Repository files navigation

qDBManager

qDBManager is a lightweight Qt/C++ data access layer for SQLite with an entity-oriented API.

It was designed for projects that want ORM-like ergonomics without external heavy dependencies.

Features

  • Basic CRUD operations
  • Entity registration and mapping
  • Criteria-based search helpers
  • SQLite adapter included (interfaces/qsqlite.h)

Integration

Add qdbmanager.pri to your Qt .pro file:

include(../qdbmanager/qdbmanager.pri)

Defining an Entity

qDBManager provides macros to simplify entity mapping:

  • Q_FIELD(type, name): mapped DB field
  • Q_TRANSIENT_FIELD(type, name): non-persisted field
  • Q_INDEX(field): single-field index
  • Q_INDEX_MUL(field1, field2): multi-field index

Minimal Usage Example

QDBManager* dbm = QDBManager::create("test", "QSQLITE");
dbm->register_entity<TestEntity>();

dbm->openDB("testdb.sqlite");
dbm->createTable<TestEntity>();

TestEntity* entity = new TestEntity();
entity->set_name("Leonard");
entity->set_surname("Hofstadter");

dbm->insertOrUpdate<TestEntity>(entity);
QListTestEntity items = dbm->listAll<TestEntity>();

dbm->closeDB();

Important: always call register_entity<YourEntity>() before loading entities.

Limitations

  • Current adapter support is SQLite only.
  • Additional adapters can be implemented by extending QDBManager.

License

See LICENSE. Hope to help someone with this lines. Every suggestion is appreciated.

About

An easy-to-use ORM/Entity Manager for Qt Framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors