Skip to content

Commit 2f75ff7

Browse files
committed
Update README.md
1 parent 6ae7116 commit 2f75ff7

1 file changed

Lines changed: 42 additions & 46 deletions

File tree

README.md

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,67 @@
11

2-
# Introduction
2+
# SQLite Cloud Client SDK for Go
33

4-
The SQLite Cloud Client SDK for Go (sqlitecloud/go-sdk) is the Go Programming Language application programmer's interface to [SQLite Cloud](https://sqlitecloud.io/).
4+
The SQLite Cloud Client SDK for Go (sqlitecloud/go-sdk) is the Go Programming Language application programmer's interface to [SQLite Cloud](https://sqlitecloud.io/). It is a set of library functions that allow client programs to pass queries and SQL commands to the SQLite Cloud backend server and to receive the results of these queries. In addition to the standard SQLite statements, several other [commands](https://docs.sqlitecloud.io/docs/commands) are supported.
55

6-
It is a set of library functions that allow client programs to pass queries and SQL commands to the SQLite Cloud backend server and to receive the results of these queries. In addition to the standard SQLite statements, several other [commands](https://docs.sqlitecloud.io/docs/commands) are supported.
6+
## Getting Started
77

8-
# Getting Started
8+
### Use the SQLite Cloud Client SDK in your Go code
99

10-
## Use the SQLite Cloud Client SDK in your Go code
10+
1. Import the package in your Go source code:
1111

12-
1. Import the package in your Go source code
12+
```go
13+
import sqlitecloud "github.com/sqlitecloud/go-sdk"
14+
```
1315

14-
```
15-
import sqlitecloud "github.com/sqlitecloud/go-sdk"
16-
```
16+
2. Download the package, and run the [`go mod tidy` command](https://go.dev/ref/mod#go-mod-tidy) to synchronize your module's dependencies:
1717

18-
2. download the package, run the [`go mod tidy` command](https://go.dev/ref/mod#go-mod-tidy) to synchronize your module's dependencies:
18+
```
19+
$ go mod tidy
20+
go: downloading github.com/sqlitecloud/go-sdk v1.0.0
21+
```
1922

20-
```
21-
$ go mod tidy
22-
go: downloading github.com/sqlitecloud/go-sdk v1.0.0
23-
```
23+
3. Connect to a SQLite Cloud database with a valid [connection string](#get-a-connection-string):
2424

25-
3. Connect to SQLite Cloud database with a valid [connection string](#get-a-connection-string)
26-
27-
```
28-
db, err := sqlitecloud.Connect("sqlitecloud://user:pass@host.sqlite.cloud:port/dbname")
29-
```
25+
```go
26+
db, err := sqlitecloud.Connect("sqlitecloud://user:pass@host.sqlite.cloud:port/dbname")
27+
```
3028

3129
4. Execute queries using a [method](#api-documentation) defined on the `SQCloud` struct, for example `Select`:
3230

33-
```
34-
result, _ := db.Select("SELECT * FROM table1;")
35-
```
36-
37-
31+
```go
32+
result, _ := db.Select("SELECT * FROM table1;")
33+
```
3834

3935
The following example shows how to print the content of the table `table1`:
4036

41-
```
37+
```go
4238
package main
4339
4440
import (
45-
"fmt"
46-
"strings"
41+
"fmt"
42+
"strings"
4743
48-
sqlitecloud "github.com/sqlitecloud/go-sdk"
44+
sqlitecloud "github.com/sqlitecloud/go-sdk"
4945
)
5046
5147
const connectionString = "sqlitecloud://admin:password@host.sqlite.cloud:8860/dbname.sqlite"
5248
5349
func main() {
54-
db, err := sqlitecloud.Connect(connectionString)
55-
if err != nil {
56-
fmt.Println("Connect error: ", err)
57-
}
58-
59-
tables, _ := db.ListTables()
60-
fmt.Printf("Tables: \n\t%s\n", strings.Join(tables, "\n\t"))
61-
62-
fmt.Printf("Table1:\n")
63-
result, _ := db.Select("SELECT * FROM t1;")
64-
for r := uint64(0); r < result.GetNumberOfRows(); r++ {
65-
id, _ := result.GetInt64Value(r, 0)
66-
value, _ := result.GetStringValue(r, 1)
67-
fmt.Printf("\t%d: %s\n", id, value)
68-
}
50+
db, err := sqlitecloud.Connect(connectionString)
51+
if err != nil {
52+
fmt.Println("Connect error: ", err)
53+
}
54+
55+
tables, _ := db.ListTables()
56+
fmt.Printf("Tables:\n\t%s\n", strings.Join(tables, "\n\t"))
57+
58+
fmt.Printf("Table1:\n")
59+
result, _ := db.Select("SELECT * FROM t1;")
60+
for r := uint64(0); r < result.GetNumberOfRows(); r++ {
61+
id, _ := result.GetInt64Value(r, 0)
62+
value, _ := result.GetStringValue(r, 1)
63+
fmt.Printf("\t%d: %s\n", id, value)
64+
}
6965
}
7066
```
7167

@@ -75,13 +71,13 @@ You can connect to any cloud database using a special connection string in the f
7571

7672
`sqlitecloud://user:pass@host.com:port/dbname?timeout=10&key2=value2&key3=value3`
7773

78-
To get a valid connection string just follow these instructions:
74+
To get a valid connection string, follow these instructions:
7975

8076
- Get a [SQLite Cloud](https://sqlitecloud.io/) account. See the [documentation](https://docs.sqlitecloud.io/docs/introduction/login) for details.
8177
- Create a [SQLite Cloud project](https://docs.sqlitecloud.io/docs/introduction/projects)
8278
- Create a [SQLite Cloud database](https://docs.sqlitecloud.io/docs/introduction/databases)
83-
- Get the connection string by clicking on the node address in the [Dashboard Nodes](https://docs.sqlitecloud.io/docs/introduction/nodes) section. A valid connection string for twill be copied in your clipboard.
84-
- add the database name to your connection string
79+
- Get the connection string by clicking on the node address in the [Dashboard Nodes](https://docs.sqlitecloud.io/docs/introduction/nodes) section. A valid connection string will be copied to your clipboard.
80+
- Add the database name to your connection string.
8581

8682
## API Documentation
8783

0 commit comments

Comments
 (0)