Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(020): enrolling 020 features #5

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENMLDB_VERSION=0.8.4
OPENMLDB_VERSION=0.8.5
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
OpenMLDB Go SDK
------

Pure Go [OpenMLDB](https://github.com/4paradigm/OpenMLDB) driver for database/sql, connect via HTTP.

## Features

## Requirements

- OpenMLDB with all components version >= 0.6.2
- OpenMLDB API Server setted up

## Installation

```sh
go get github.com/4paradigm/openmldb-go-sdk
```

## Data Source Name (DSN)

```
openmldb://<API_SERVER_HOST>:<API_SERVER_PORT>/<DB_NAME>
```

For example, to open a database to `test_db` by api server at `127.0.0.1:8080`:
```go
db, err := sql.Open("openmldb", "openmldb://127.0.0.1:8080/test_db")
```

## Getting Start

```go
package main

import (
"context"
"database/sql"

_ "github.com/4paradigm/openmldb-go-sdk"
)

func main() {
db, err := sql.Open("openmldb", "openmldb://127.0.0.1:8080/test_db")
if err != nil {
panic(err)
}

defer db.Close()

ctx := context.Background()

// execute DDL
if _, err := db.ExecContext(ctx, `CREATE TABLE demo (c1 int, c2 string);`); err != nil {
panic(err)
}

// execute DML
if _, err := db.ExecContext(ctx, `INSERT INTO demo VALUES (1, "bb"), (2, "bb");`); err != nil {
panic(err)
}

// execute DQL
rows, err := db.QueryContext(ctx, `SELECT c1, c2 FROM demo;`)
if err != nil{
panic(err)
}

var col1 int
var col2 string

// iterating query result
for rows.Next() {
if err := rows.Scan(&col1, &col2); err != nil {
panic(err)
}
println(col1, col2)
}
}
```