Version0.2.0
Revision67
Size1.0 MB
LicenseApache-2.0
Confinementstrict
Basecore18
CategoriesDevelopment

C library providing simple and easy to use interfaces to the ODBC API


Icon based on "Database free icon" by smashicons from www.flaticon.com and "ready" by Arbcom from https://commons.wikimedia.org

Example code

 #include "cdbc.h"
 
 int main(int argc, char **argv) {
     CDBC cdbc;
     CDBCQUERY q;
     CDBCRESULT res;
     char *rowvalue;
     int id = 1;
     
     // initialize CDBC and connect
     cdbc = cdbcinit();
     cdbcconnect(cdbc, "MySQL", "DATABASE=mydb", "127.0.0.1", 3306, "username", "password");
     
     // prepare SQL query
     q = cdbcprepare(cdbc, "SELECT * FROM table WHERE id = ?");
     
     // bind input parameters
     cdbcbindparam(q, 1, CDBCCLONG, id, sizeof(id));
     
     // execute SQL query
     cdbcexecute(q);
     
     // get pointer to row in resultset
     rowvalue = cdbccname(q, "rowname");
     
     // fetch data
     res = cdbcfetch(q);
     while (res) {
         printf("%s\n", rowvalue);
         res = cdbcfetch(q);
     }
     
     // clean up
     cdbcfinish(q);
     cdbcdisconnect(cdbc);
     cdbc_cleanup(cdbc);
     
     return 0;
 }
 

Have a look at https://github.com/fnordahl/cdbc/blob/master/tests/test.c
for more a more complete example with error handling etc.

The functional tests (https://github.com/fnordahl/cdbc/blob/master/.travis.yml)
for this repository contain some hints about consuming the library from your
snap: https://github.com/fnordahl/cdbc/blob/master/tests/snap/snapcraft.yaml

Update History

0.2.0 (67)
13 Dec 2025, 09:47 UTC

Published15 Oct 2017, 02:39 UTC

Last updated18 May 2021, 10:04 UTC

First seen13 Dec 2025, 09:47 UTC