4 // #include <dbi/dbi.h>
12 type DBIConnection struct {
13 dbconn unsafe.Pointer;
17 func DBICreate()(connection *DBIConnection)
19 var dbCon *DBIConnection;
21 dbCon = new(DBIConnection);
27 //func (thisDBConn *DBIConnection)DBIConnect(dbtype string, host string, username string, password string, database string)
28 // for some reason, the above doesnt work how i'd expect..
29 func DBIConnect(thisDBConn *DBIConnection, dbtype string, host string, username string, password string, database string)
31 C.dbi_initialize(nil);
33 thisDBConn.dbconn = (unsafe.Pointer)(C.dbi_conn_new(C.CString(dbtype)));
35 C.dbi_conn_set_option(thisDBConn.dbconn, C.CString("host"), C.CString(host));
36 C.dbi_conn_set_option(thisDBConn.dbconn, C.CString("username"), C.CString(username));
37 C.dbi_conn_set_option(thisDBConn.dbconn, C.CString("password"), C.CString(password));
38 C.dbi_conn_set_option(thisDBConn.dbconn, C.CString("dbname"), C.CString(database));
39 C.dbi_conn_connect(thisDBConn.dbconn);
41 thisDBConn.dbinit = true;
44 func ExecSQL(thisDBConn *DBIConnection, SQL string)
46 fmt.Printf("%s;\n", SQL);
47 res := C.dbi_conn_query(thisDBConn.dbconn, C.CString(SQL));
49 C.dbi_result_free((unsafe.Pointer)(res));
52 func DBIDisconnect(thisDBConn *DBIConnection)
54 C.dbi_conn_close(thisDBConn.dbconn);