File: example_test.go

package info (click to toggle)
golang-github-zombiezen-go-sqlite 1.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: makefile: 3
file content (28 lines) | stat: -rw-r--r-- 523 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2021 Roxy Light
// SPDX-License-Identifier: ISC

package shell_test

import (
	"fmt"
	"os"

	"zombiezen.com/go/sqlite"
	"zombiezen.com/go/sqlite/shell"
)

// This is a small program that emulates the behavior of the sqlite3 CLI.
// A path to a database can be passed on the command-line.
func Example() {
	dbName := ":memory:"
	if len(os.Args) > 1 {
		dbName = os.Args[1]
	}
	conn, err := sqlite.OpenConn(dbName)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	shell.Run(conn)
	conn.Close()
}