Page 1 of 1
pixilang on andriod with sqlite
Posted: Tue May 28, 2013 12:32 am
by kmatze
hi nightradio,
is it possible to make core support in pixilang to use sqlite database?
greetings kmatze
Re: pixilang on andriod with sqlite
Posted: Tue May 28, 2013 3:52 pm
by NightRadio
Hi!
I believe you can include sqlite using dlopen() and dlcall() functions.
As for the core support - i don't think it is necessary for Pixilang :)
Re: pixilang on andriod with sqlite
Posted: Fri Aug 02, 2013 9:01 pm
by kmatze
hi nightradio,
NightRadio wrote:Hi!
I believe you can include sqlite using dlopen() and dlcall() functions.
As for the core support - i don't think it is necessary for Pixilang
I try and try but it don't go (under windows).
Thats the
definition of sqlite-function:
int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
in pixilang:
SQLite = dlopen( "sqlite3.dll")
if SQLite >= 0 {
sql_open = dlsym(SQLite, "sqlite3_open", "v(pp)")
if sql_open >= 0 {
retval = dlcall( SQLite, sql_open, "test.db", "DB")
}
dlclose( SQLite )
}
The result is an windows system error.
where is the mistake? How to declare a handle?
thanks and greetings - kmatze
Re: pixilang on andriod with sqlite
Posted: Sat Aug 03, 2013 6:01 pm
by NightRadio
retval = dlcall( SQLite, sql_open, "test.db", "DB")
Hm... But what is "DB" in your code?
I'm not sure about sqlite, but can you provide some C/C++ source where sqlite3_open() is used?
Re: pixilang on andriod with sqlite
Posted: Sun Aug 04, 2013 1:18 pm
by kmatze
hi nightradio,
NightRadio wrote:retval = dlcall( SQLite, sql_open, "test.db", "DB")
Hm... But what is "DB" in your code?
I'm not sure about sqlite, but can you provide some C/C++ source where sqlite3_open() is used?
DB should be the handle for the opend database file. DB ist used in the other calls of sqlite.
thats the declaration/definition/function in c (to call from pixilang):
Code: Select all
int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
and the usage in c:
Code: Select all
rc = sqlite3_open("test.db", &db);
the next statement is to use the open database file (handle) to execute a sql statement, here the c-function:
Code: Select all
sys sqlite3_exec (sys db,char* s, sys p1, sys p2, sys*dberr)
where db = handle of open database file
s = callback function
p1 = callback function
p2 = parameter list for callback function
dberr = errormessage
and the uage in c:
Code: Select all
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
the c usage in summary thats I want to use in pixilang, but how?
Code: Select all
rc = sqlite3_open("test.db", &db);
rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
sqlite3_close(db);
//
// and the callback function
//
static int callback(void *data, int argc, char **argv, char **azColName)
thanks and greetings - kmatze
Re: pixilang on andriod with sqlite
Posted: Sun Aug 04, 2013 6:46 pm
by NightRadio
Ok, please try the following:
Code: Select all
SQLite = dlopen( "sqlite3.dll")
if SQLite >= 0 {
sql_open = dlsym( SQLite, "sqlite3_open", "v(pp)" )
if sql_open >= 0 {
//ppDb is a pointer to pointer. In the 32bit system the pointer size is 4 bytes.
//So we just need a four-byte container. Here is the simplest way to create such container:
ppDb = "1234" //Four bytes (32bit pointer)
//And then use the pointer to ppDb in the open() function:
retval = dlcall( SQLite, sql_open, "test.db", ppDb )
}
dlclose( SQLite )
}