Commit 3a39bd89 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

sqlite tested on android

parent 7a76e2dc
......@@ -15,12 +15,36 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define db "test.db")
(define db "/sdcard/mongoose/test.db")
(display (db-open db))(newline)
(display (db-status db))(newline)
(db-exec db "CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL );")
(display (db-status db))(newline)
(db-exec db "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Paul', 32, 'California', 20000.00 );
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Allen', 25, 'Texas', 15000.00 );
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );")
(display (db-status db))(newline)
(display (db-exec db "select * from COMPANY"))(newline)
(display (db-status db))(newline)
(define (mbutton id title fn)
(button (make-id id) title 20 fillwrap fn))
......
......@@ -79,7 +79,7 @@ list *db::exec(const char *sql)
if( rc != SQLITE_OK )
{
snprintf(m_status,4096,"SQL error: %s",err);
m_running=0;
//m_running=0;
sqlite3_free(err);
}
else
......
......@@ -27,6 +27,7 @@ public:
~db();
list *exec(const char *sql);
const char *status() { return m_status; }
class value_node: public list::node
{
......
......@@ -194,6 +194,7 @@
_OP_DEF(opexe_6, "send", 1, 1, TST_NONE, OP_SEND )
_OP_DEF(opexe_6, "db-open", 1, 1, TST_NONE, OP_OPEN_DB )
_OP_DEF(opexe_6, "db-exec", 2, 2, TST_NONE, OP_EXEC_DB )
_OP_DEF(opexe_6, "db-status", 1, 1, TST_NONE, OP_STATUS_DB )
#undef _OP_DEF
......@@ -4286,6 +4286,16 @@ static pointer opexe_6(scheme *sc, enum scheme_opcodes op) {
}
s_return(sc,sc->F);
}
case OP_STATUS_DB: {
if (is_string(car(sc->args))) {
db *d=the_db_container.get(string_value(car(sc->args)));
if (d!=NULL)
{
s_return(sc,mk_string(sc,d->status()));
}
}
s_return(sc,sc->F);
}
////////////////////
default:
snprintf(sc->strbuff,STRBUFFSIZE,"%d: illegal operator", sc->op);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment