Go

The litesync/go-sqlite3 wrapper allows Go programs to interface with the pre-installed LiteSync library.


Instructions

First follow the instructions to compile and install LiteSync from the source code or use the pre-compiled binaries for your platform. You can start with the free version.

Then download the wrapper using this command:

go get github.com/litesync/go-sqlite3

Note: The wrapper uses the already installed SQLite library containing LiteSync. So it must be present on the device.

For more information check the instructions at the go-sqlite3 repository.


Example code
package main

import (
  "database/sql"
  _ "github.com/litesync/go-sqlite3"
  "time"
)

func main() {
  db, err := sql.Open("sqlite3", "file:test.db?node=secondary&connect=tcp://127.0.0.1:1234")
  if err != nil {
    println("failed to open the database: " + err.Error())
    return
  }

  // wait until the db is ready
  for !db.IsReady() {
    time.Sleep(1000 * time.Millisecond)
  }

  // now we can access the db
  println("OK, ready!")
}


Check also the go-sqlite3 usage examples