hi nightradio,
is it possible to make core support in pixilang to use sqlite database?
greetings kmatze
pixilang on andriod with sqlite
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: pixilang on andriod with sqlite
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 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
hi nightradio,
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
I try and try but it don't go (under windows).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
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
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: pixilang on andriod with sqlite
Hm... But what is "DB" in your code?retval = dlcall( SQLite, sql_open, "test.db", "DB")
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
hi nightradio,
thats the declaration/definition/function in c (to call from pixilang):
and the usage in c:
the next statement is to use the open database file (handle) to execute a sql statement, here the c-function:
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:
the c usage in summary thats I want to use in pixilang, but how?
thanks and greetings - kmatze
DB should be the handle for the opend database file. DB ist used in the other calls of sqlite.NightRadio wrote:Hm... But what is "DB" in your code?retval = dlcall( SQLite, sql_open, "test.db", "DB")
I'm not sure about sqlite, but can you provide some C/C++ source where sqlite3_open() is used?
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 */
);
Code: Select all
rc = sqlite3_open("test.db", &db);
Code: Select all
sys sqlite3_exec (sys db,char* s, sys p1, sys p2, sys*dberr)
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);
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)
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: pixilang on andriod with sqlite
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 )
}