Guys I am trying to get info from a mysql database that stores the date in a string format and return UTC format as well as a associated value. I can use the following select() statement OK to take care of that : mysql> select UNIX_TIMESTAMP(<Timestamp string>),<data fields> from <table>;
This gives all the values in the table and the UTC timeformat So, next I built libdbi was able to run a simple db connection to test it all worked. I then moved on to try the above and got my values OK but I get '0''s for the UTC TIMESTAMP. Anyone any ideas why this doesn't work? Cheers Here's my src which compiles and runs OK but gives the partial output below.. Any ideas ( I have played with the printf statement already ;-) ? #include <stdio.h> #include </usr/local/include/dbi/dbi.h> int main() { dbi_conn conn; dbi_result result; unsigned int updateLatency; unsigned int time; const char *name; dbi_initialize(NULL); conn = dbi_conn_new("mysql"); dbi_conn_set_option(conn, "host", "localhost"); dbi_conn_set_option(conn, "username", "sqluser"); dbi_conn_set_option(conn, "password", ""); dbi_conn_set_option(conn, "dbname", "test"); 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 UNIX_TIMESTAMP(HIST_Timestamp),HIST_Node,updateLatency from TABLE"); if (result) { while (dbi_result_next_row(result)) { name = dbi_result_get_string(result, "HIST_Node"); time = dbi_result_get_uint(result, "UNIX_TIMESTAMP(HIST_Timestamp)"); updateLatency = dbi_result_get_uint(result, "updateLatency"); printf("%s %d %d\n",name,updateLatency,time); } dbi_result_free(result); } dbi_conn_close(conn); } dbi_shutdown(); return 0; } Sample Output: chimds05 34 0 chimds05 12 0 chimds05 13 0 chimds05 20 0 chimds05 10 0 chimds05 13 0 This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.
<<Glacier Bkgrd.jpg>>
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ libdbi-users mailing list libdbi-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-users