2

I am New to Sqlite and LiveCode.I need to do some tasks with liveCode and SqlLite.Can anyone let me know what is suitable version of Sqlite for the LiveCode and from where i can download it as i am not finding anything sufficient information on the web regarding it.Thanks

Rohit Bhardwaj
  • 269
  • 4
  • 20

2 Answers2

4

There is a sqlite driver included in LiveCode. Just read up on the revDB functions and commands. This tutorial will probably help you out:

http://lessons.runrev.com/s/lessons/m/4071/l/30516-how-to-create-and-use-an-sqlite-database

The current version distributed with LiveCode is 3.7.4

Monte Goulding
  • 2,380
  • 1
  • 21
  • 25
  • Thanks, I assume LiveCode 6.1? – z-- Jul 07 '13 at 06:17
  • Monte, you mean here https://github.com/runrev/livecode/tree/master/revdb? Where exactly in that folder? – z-- Jul 08 '13 at 09:17
  • The current version of livecode's SQLite version is 3.34.0 as of Livecode 9.6.8. As derived from running "select sqlite_version();" Please edit your answer Monte, its from the future. :) – makeshyft_tom Aug 09 '22 at 14:44
3

In LiveCode 6 do the following

  • go to menu Help
  • choose Example Stacks and Resources
  • open the Examples folder
  • double click on SQLite Sampler.rev . The stack SQLite Sampler.rev contains explanations and code snippets.
  • Adapt the example code snippets to your needs.

For example the following snippet taken from that stack connects to a database AppReg3.db. The database is created if it does not exist yet.

gConID holds the connection identifier to refer to the database in later scripts.

# Connect button script
on mouseUp
  global gConID
  put revOpenDatabase("sqlite","AppReg3.db",,,,,,) into tConID
  if tConID is "" then 
    answer warning "Problem creating or accessing database!"
  else
    answer information "AppReg Connected! Your connection ID is: " & tConID
    put tConID into gConID
  end if
end mouseUp

The following creates a table Users

on mouseUp
  global gConID
  if gConID is "" then
    answer information "No Database is Connected to, please go back 1 step and connect to the Database!"
    exit mouseUp
  end if
  put "CREATE TABLE users(userID integer primary key, name text,email text,emailList boolean)" into tSQL
  put revExecuteSQL(gConID,tSQL) into tTmp
  handleRevDBerror tTmp
  if the result is not empty then 
    answer warning the result
    exit mouseUp
  end if
  answer information "Number of Tables Added: " & tTmp
 end mouseUp
z--
  • 2,186
  • 17
  • 33
  • Thanks Hanes..where should i store my sqlite database..and when i make a build of the project is database automatically encapsulate in the build.? – Rohit Bhardwaj Jul 05 '13 at 11:24
  • Please do a new question for this 'Location for sqlite database?' – z-- Jul 07 '13 at 06:15