Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An ActiveRecord style Sqlite Library using FMDB

branch: master
README.md

rubymotion-sqlite

An ActiveRecord style Sqlite Library using FMDB

check lib/sqlite.rb for the code

running the current code base

$ rake
....

# class Wordlist < Sqlite
# ...."create table wordlist (id INTEGER PRIMARY KEY, word varchar(20),length int, UNIQUE(word));"
#end

(main)>> 
s = Wordlist.new
s.createTable
s.insert_data('Shweta')
s.insert_data('Sampoorna')
s.insert_data('Senthil')
s.insert_data('HELLO')
s.insert_data('WORLD')

results= s.find(:all)
[{"word"=>"Shweta", "id"=>"1", "length"=>"6"}, {"word"=>"Sampoorna", "id"=>"2", "length"=>"9"}, {"word"=>"Senthil", "id"=>"3", "length"=>"7"},{"word"=>"HELLO", "id"=>"4", "length"=>"5"},{"word"=>"WORLD", "id"=>"5", "length"=>"5"}]

persistence works, exit the app and start again

(main)>  w = Wordlist.new
=> #<Wordlist:0x8b2b180 @db=#<FMDatabase:0x8b2b320> @values=nil @table="wordlist">
(main)> w.find(:first)
 first
SELECT select * from wordlist limit 1
=> [{"word"=>"Shweta", "id"=>"1", "length"=>"6"}]
(main)> w.length
=> 6
(main)> w.id
=> 1
(main)> w.word
=> "Shweta"

what works

  • create table
  • insert data
  • find(:first), find(:last),find(:all)
  • result is a array of hash with the key corresponding to the column name
  • data is not persisted beyond a session - solved

todo

  • no exception handling, so if you have any sqlite constraints like unique then gives error, or if table already exists
  • data type conversion
  • need to plan for migration
  • pre-populated data
  • currently table structure is hardcoded in the class, hope I would get models to extend from the base model, with least duplication of the code

Word Games

To Do

  • get word lists
  • write a script to build the sqlite database
  • search by word length and letters included
  • anagram builder
Something went wrong with that request. Please try again.