-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
52 lines (41 loc) · 1.57 KB
/
doc.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Package sqlitemeta provides access to SQLite metadata, such as table,
column and index information.
To use this package, establish an SQLite connection (via the database/sql
package) and pass the resulting database handle to the sqlitemeta functions,
e.g.
db, err := sql.Open("sqlite3", "/path/to/sqlite.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
tables, err := sqlitemeta.TableNames(db)
if err != nil {
log.Fatal(err)
}
for _, tbl := range tables {
indexes, err := sqlitemeta.Indexes(db, tbl)
if err != nil {
log.Fatal(err)
}
fmt.Println("Table", tbl, "has the following indexes")
for _, in := range indexes {
fmt.Println(" -", in.Name)
}
fmt.Println()
}
Multiple Databases
In SQLite, a single database connection can access multiple databases,
each with their own schemas and data. In this package, an individual
database is represented by the Schema type.
Most of the top-level functions in this package have matching methods
on the Schema type. Use the Schema methods to restrict scope to a
particular database. Use the top-level functions to operate on the
main database or, for functions that take a table or index name, to
search across all available databases.
When SQLite searches its databases for a particular table or index,
the temp database takes precedence, followed by the main database,
followed by any other attached databases (in order of attachment).
See https://sqlite.org/lang_naming.html for details.
*/
package sqlitemeta