Skip to content

aykl/purescript-sqlite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-sqlite

Latest release

Installation

bower install purescript-sqlite

npm install sqlite3

Example

instance loremIsForeign :: IsForeign Lorem where
  read obj = do
    n <- readProp "info" obj
    pure $ Lorem { info: n }

instance showLorem :: Show Lorem where
  show (Lorem a) = a.info

data Lorem = Lorem { info :: String }

main :: forall e. Eff (err :: EXCEPTION, console :: CONSOLE, sqlite :: SQLITE | e)
                  (Canceler ( sqlite :: SQLITE, console :: CONSOLE | e ))
main = launchAff $ do
  db <- connect ":memory:" ReadWriteCreate
  run db "CREATE TABLE IF NOT EXISTS lorem (info TEXT)"
  run db ("INSERT INTO lorem VALUES (${value})" <-> [ "value" /\ "fooish!" ])
  rows <- get db "SELECT * from lorem" :: SqlRows Lorem
  close db

  case rows of
    Left err -> log (message err)
    Right rows' -> log $ show rows' 

This example logs [fooish!] to the console.

For more examples, see the unit tests and examples folder.

Packages

No packages published

Languages

  • PureScript 81.1%
  • JavaScript 18.9%