Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137

    SQLite database in MEMORY only!

    Note: You will need AMS 5.x Pro and the SQLite plugin installed before you try to view this project!

    I had a couple minutes and wanted to keep my SQLite "sharpness". So, I went ahead and coded this small project file to explain how to create a SQLite database, insert records into it, query it (get a list of data), and then output it (show it up in the Debug window). The neat (well to me anyway) part is that this SQLite database is "memory" loaded only (no files!). Much like a table (array) in AMS 5! But, with the SQLite I like that I can use the SQL on the data and output more easily what I want! Filtering even is easier (get only the data I need/want).
    Please note that I "on purpose" did not include error correction code. This was done to keep it easy to understand how the SQLite plugin works, at least in this one instance.

    But, you should always add error correction code into your projects, not just for the SQLite database!


    [ADDED IN CODE FOR VIEWING]

    Code:
    -- Open the database (db), if it has not already been created
    db = SQLite.Open(":memory:")
    
    -- Create the various tables in the database
    SQLite.Query(db, "CREATE TABLE sqlData(userid INTEGER PRIMARY KEY, LastName TEXT, FirstName TEXT, Country TEXT)")
    
    -- Add some data into the database (db)
    SQLite.Query(db, "Insert into sqlData values(Null, 'Finklestein', 'Roger', 'Utah')")
    SQLite.Query(db, "Insert into sqlData values(Null, 'Ballard', 'Tim', 'California')")
    SQLite.Query(db, "Insert into sqlData values(Null, 'Smortz', 'Barbara', 'Pennsylvania')")
    
    -- Create an AMS table (tblRS) out of the SQLite database (db)
    tblRS = SQLite.QueryToTable(db, "Select * from sqlData")
    
    -- For each row of data (which are numbered) print out all of its data
    for c=1, tblRS.Rows do
    	Debug.ShowWindow(true)
    	Debug.Print(tblRS.Data[c]["userid"]..".\r\n")
    	Debug.Print(tblRS.Data[c]["FirstName"].."\r\n")
    	Debug.Print(tblRS.Data[c]["LastName"].."\r\n")
    	Debug.Print(tblRS.Data[c]["Country"].."\r\n\r\n")
    	
    end
    
    -- 'Not' always needed!  But, it's recommended after manipulating a SQLite database.
    SQLite.Close(db)
    Attached Images
    Attached Files
    Last edited by Intrigued; 05-11-2005 at 10:13 AM.
    Intrigued

  2. #2
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Nice snippet, Intrigued.. Thanks!

    Do you have a lot of these "free couple of minutes"?...

    Yossi

  3. #3
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Quote Originally Posted by yosik
    Nice snippet, Intrigued.. Thanks!

    Do you have a lot of these "free couple of minutes"?...

    Yossi
    Only if I make time for them.

    Intrigued

  4. #4
    Join Date
    Sep 2009
    Posts
    5
    thnk you sir

  5. #5
    Join Date
    Jul 2008
    Posts
    88
    thx....

  6. #6
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    You're welcome. It's good to see posts from years past still relevant and helpful.
    Intrigued

Similar Threads

  1. SQLite Database Browser - New Version!
    By Intrigued in forum AutoPlay Media Studio 5.0
    Replies: 9
    Last Post: 11-10-2009, 06:14 AM
  2. How to convert access database to sqlite database.
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 07-22-2008, 07:44 PM
  3. SQLite database help.
    By ianhull in forum AutoPlay Media Studio 5.0
    Replies: 1
    Last Post: 11-21-2004, 02:11 PM
  4. SQLite Database Browser
    By Brett in forum AutoPlay Media Studio 5.0
    Replies: 6
    Last Post: 07-26-2004, 01:03 PM
  5. Spotlight: SQLite Actions Plugin
    By Desmond in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 03-12-2004, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts