Giter VIP home page Giter VIP logo

go-libsql's Introduction

LibSQL package for Go

libSQL is an open source, open contribution fork of SQLite. This source repository contains libSQL API bindings for Go.

Notice

This package comes with a precompiled native libraries. Currently only darwin amd64 and darwin arm64 are supported. We're working on adding support for more platforms.

Features

  • In-memory databases and local database files, like SQLite
  • Remote database access to libSQL server
  • In-app replica that syncs with a libSQL server

Installing

go get github.com/tursodatabase/go-libsql

go-libsql uses CGO to make calls to LibSQL. You must build your binaries with CGO_ENABLED=1.

Getting Started

Connecting to the database

To connect to the database one needs to create a libsql.Connector using one of the factory functions: libsql.NewEmbeddedReplicaConnector or libsql.NewEmbeddedReplicaConnectorWithAutoSync.

Here's an example of obtaining a sql.DB object from database/sql package:

dbPath := // Path do db file on local disk
primaryUrl := // URL to primary database instance
connector := NewEmbeddedReplicaConnector(dbPath, primaryUrl, authToken)
db := sql.OpenDB(connector)
defer db.Close()

Once sql.DB object is created one can use it as any other database that supports database/sql package.

Fetching updates from primary database instance

If the connector is created with libsql.NewEmbeddedReplicaConnectorWithAutoSync then it will automatically fetch updates from a primary periodically.

For connectors created with libsql.NewEmbeddedReplicaConnector we need to fetch updates manually by calling connector.Sync

Examples

Module with usage examples can be found in example directory.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libSQL by you, shall be licensed as MIT, without any additional terms or conditions.

go-libsql's People

Contributors

haaawk avatar penberg avatar lahickey avatar funbiscuit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.