Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

libSQL API for Go

License

NotificationsYou must be signed in to change notification settings

tursodatabase/go-libsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 onlylinux amd64,linux arm64,darwin amd64 anddarwin 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 usesCGO to make calls to LibSQL. You must build your binaries withCGO_ENABLED=1.

Getting Started

Connecting to the database

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

Here's an example of obtaining asql.DB object fromdatabase/sql package:

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

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

Fetching updates from primary database instance

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

For connectors created withlibsql.NewEmbeddedReplicaConnector we need to fetch updates manually by callingconnector.Sync

Examples

Module with usage examples can be found inexample directory.

License

This project is licensed under theMIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in libSQL by you, shall be licensed as MIT, without any additionalterms or conditions.

About

libSQL API for Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors14

Languages


[8]ページ先頭

©2009-2025 Movatter.jp