database.h 826 B

123456789101112131415161718192021222324252627282930
  1. /* Simple SQL-style database ops. Currently implemented for sqlite3. */
  2. //#ifndef _UPLOAD_ANALYSIS_DATABASE_H
  3. //#define _UPLOAD_ANALYSIS_DATABASE_H
  4. #include <stdbool.h>
  5. /* Returns handle to the database.. */
  6. void *db_open(const char *file);
  7. /* Runs query (SELECT). Fills in columns. */
  8. struct db_query
  9. {
  10. unsigned int num_rows;
  11. char ***rows;
  12. };
  13. struct db_query *db_query(void *h, const char *query);
  14. /* Runs command (CREATE TABLE/INSERT) */
  15. void db_command(void *h, const char *command);
  16. /* Starts transaction. Doesn't need to nest. */
  17. //void db_transaction_start(void *h);
  18. /* Finishes transaction, or rolls it back and caller needs to start again. */
  19. //bool db_transaction_finish(void *h);
  20. /* Closes database (only called when everything OK). */
  21. void db_close(void *h);
  22. //#endif /* _UPLOAD_ANALYSIS_DATABASE_H */