GameMonkey Script

GameMonkey Script Forums
It is currently Thu May 23, 2019 2:41 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: SQLite Bind
PostPosted: Sun May 10, 2009 1:42 pm 

Joined: Sat Apr 25, 2009 1:40 am
Posts: 66
I know someone has made one of these before, but i couldn't find a working download link so i just made a new one. I think the query code was programmed by Dr-Evil.

gmSQLite.rar [2.02 KiB]
Downloaded 330 times

New global functions:
SQLite SQLite() - Returns a new "SQLite" object.
string SQLiteEscape(string) - "Escapes" a string so it is suitable within an SQLite query. IE, "Luke'Graham" changes to "Luke''Graham" (double single quotes).

note: i use gmStreamBufferDynamic for SQLiteEscape. I hope that is suitable

New user type functions:
bool SQLite.Open(string) - Opens/Creates database file
void SQLite.Close() - Closes the currently opened database
int SQLite.Execute(string) - Execute the SQL text and returns the error code. Use "Query" if you're doing a "SELECT". This one doesn't return results.
table|null SQLite.Query(string) - Executes the query and returns a new table containing the results if there is no error. Returns null on an error.
int SQLite.LastError() - Returns the last error code
string SQLite.LastErrorText() - Returns the details for the last error

db = SQLite();

  print("Database Opened");

  result = db.Query("SELECT * from accounts");

    foreach(column in result)
      foreach(field and value in column)
        print("Field: " + field);
        print("Value: " + value);
  } else {
    print("Error code:" + db.LastError());
    print("Details:" + db.LastErrorText());


Requires sqlite3.

EDIT: Added SQLite.Execute.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group