Giter Club home page Giter Club logo

go-sqlite's Introduction

Tests badge

go-sqlite

This is a pure-Go SQLite driver for Golang's native database/sql package. The driver has Go-based implementation of SQLite embedded in itself (so, you don't need to install SQLite separately)

Usage

Example

package main

import (
	"database/sql"
	"log"

	_ "github.com/glebarez/go-sqlite"
)

func main() {
	// connect
	db, err := sql.Open("sqlite", ":memory:")
	if err != nil {
		log.Fatal(err)
	}

	// get SQLite version
	_ = db.QueryRow("select sqlite_version()")
}

Connection string examples

  • in-memory SQLite: ":memory:"
  • on-disk SQLite: "path/to/some.db"
  • Foreign-key constraint activation: ":memory:?_pragma=foreign_keys(1)"

Settings PRAGMAs in connection string

Any SQLIte pragma can be preset for a Database connection using _pragma query parameter. Examples:

Multiple PRAGMAs can be specified, e.g.:
path/to/some.db?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)

go-sqlite's People

Contributors

amenzhinsky avatar artyom avatar comaldave avatar cznic avatar danp avatar demired avatar dependabot[bot] avatar fabianexe avatar fastcat avatar glebarez avatar jaicewizard avatar jasontashtego avatar lsnow99 avatar michahoffmann avatar saedx1 avatar steffengy avatar yaslama avatar zombiezen 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.