package dbibridge // #include // #include import "C" import ( "unsafe"; ) type DBConnection struct { dbconn C.dbi_conn; dbinit bool; } func DBICreate()(connection *DBConnection) { var dbCon *DBConnection; dbCon = new(DBConnection); dbCon.dbinit = false; return dbCon; } //func (thisDBConn *DBConnection)DBIConnect(dbtype string, host string, username string, password string, database string) // for some reason, the above doesnt work how i'd expect.. func DBIConnect(thisDBConn *DBConnection, dbtype string, host string, username string, password string, database string) { C.dbi_initialize(nil); thisDBConn.dbconn = C.dbi_conn_new(C.CString(dbtype)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("host"), C.CString(host)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("username"), C.CString(username)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("password"), C.CString(password)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("dbname"), C.CString(database)); C.dbi_conn_connect((unsafe.Pointer)(thisDBConn.dbconn)); thisDBConn.dbinit = true; } func ExecSQL(thisDBConn *DBConnection, SQL string) { C.dbi_conn_query((unsafe.Pointer)(thisDBConn.dbconn), C.CString(SQL)); } func DBIDisconnect(thisDBConn *DBConnection) { C.dbi_conn_close((unsafe.Pointer)(thisDBConn.dbconn)); }