I use sqlite3 with c language recently. Can anyone tell me some convenient ORM for c? Is there necessay to develop a ORM mechanism for my own projects?
Having a need for ORM suggests to me that you have some sort of business / domain object model in mind that you want to map to a database.
If that is the case, then it strikes me that you are trying to write a business application in a language best suited for systems programming (C). You might want to consider whether this is a good architectural strategy.
Furthermore, I don't think ORM is ever likely to be a good fit for a language that:
Finally, there are plenty of people who believe that ORM is an anti-pattern in any case. (example, example, example)
Overall, my suggestion would be to either:
i wrote this library as an "ORM for C".
example code looks like:
typedef struct person {
int id;
char *name;
} person;
void find_by_name(isti_db *db, const char *text, person** result) {
corm_person_select *s;
corm_person_select_alloc(&s, db);
s->name(s, "like", text)->_go_one(s, result); // populate result from the database
s->_free(s, 0); // in "real" code, 0 is a chained status value
}
unfortunately, it's not in use anywhere (as far as i know) and it includes quite a few ideas that seasoned c programmers might find odd. but it's not abandoned - i am still interested in the problem and hope to continue work on it at some point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With