Subject Re: Models for future firebird api
Author marius popa
On Fri, Oct 10, 2008 at 11:26 AM, marius popa <mapopa@...> wrote:
> Just an starting point , we have to do more research on postgresql,
> sqlite , mysql and compare them with our own api
>
> I wish firebird was more simpler to use similar to dbi api for example
> (that i use in perl world)
I have installed lidbi and libdbi-driver for firebird
http://mapopa.blogspot.com/2008/10/installing-and-libdbi-for-c-and-libdbi.html

http://libdbi.sourceforge.net/docs/programmers-guide/quickstart-code.html

Here is how the example should look for firebird

gedit employee.fdb

#include <stdio.h>
#include <dbi/dbi.h>

int main() {
dbi_conn conn;
dbi_result result;

double threshold = 4.333333;
unsigned int idnumber;
const char *fullname;

dbi_initialize(NULL);
conn = dbi_conn_new("firebird");

dbi_conn_set_option(conn, "host", "localhost");
dbi_conn_set_option(conn, "username", "SYSDBA");
dbi_conn_set_option(conn, "password", "masterkey");
dbi_conn_set_option(conn, "dbname",
"/var/lib/firebird/2.1/data/employee.fdb");
dbi_conn_set_option(conn, "encoding", "UTF-8");

if (dbi_conn_connect(conn) < 0) {
printf("Could not connect. Please check the option settings\n");
}
else {
result = dbi_conn_queryf(conn, "SELECT EMP_NO, FIRST_NAME FROM EMPLOYEE");

if (result) {
while (dbi_result_next_row(result)) {
idnumber = dbi_result_get_uint(result, "ENP_NO");
fullname = dbi_result_get_string(result, "FIRST_NAME");
printf("%i. %s\n", idnumber, fullname);
}
dbi_result_free(result);
}
dbi_conn_close(conn);
}

dbi_shutdown();

return 0;
}

gcc -lm -ldl -ldbi employee.c

for the moment it crashes
--
developer flamerobin.org