An open API service indexing awesome lists of open source software.

https://github.com/oceanbase/obkv-table-client-go


https://github.com/oceanbase/obkv-table-client-go

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# obkv-table-client-go
OBKV Table Client is go Library that can be used to access table data from OceanBase storage layer. Its access method is different from JDBC, it skips the SQL parsing layer, so it has significant performance advantage.

## Quick Start
Create table in the OceanBase database:

``` sql
CREATE TABLE IF NOT EXISTS `test` (
`c1` bigint(20) NOT NULL,
`c2` bigint(20) NOT NULL,
PRIMARY KEY (`c1`)
) PARTITION BY KEY(`c1`) PARTITIONS 10;
```

The code demo:
``` go
const (
configUrl = "ob-configserver-url"
fullUserName = "user@tenant#cluster"
passWord = ""
sysUserName = "root"
sysPassWord = ""
tableName = "test"
)

cfg := config.NewDefaultClientConfig()
cli, err := client.NewClient(configUrl, fullUserName, passWord, sysUserName, sysPassWord, cfg)
if err != nil {
panic(err)
}

// insert
rowKey := []*table.Column{table.NewColumn("c1", int64(1))}
insertColumns := []*table.Column{table.NewColumn("c2", int64(2))}
affectRows, err := cli.Insert(
context.TODO(),
tableName,
rowKey,
insertColumns,
)
if err != nil {
panic(err)
}
fmt.Println(affectRows)

// get
selectColumns := []string{"c1", "c2"}
result, err := cli.Get(
context.TODO(),
tableName,
rowKey,
selectColumns,
)
if err != nil {
panic(err)
}
fmt.Println(result.Value("c1"))
fmt.Println(result.Value("c2"))
```
**NOTE:**
1. configUrl is generated by [ConfigServer](https://ask.oceanbase.com/t/topic/35601923).
2. fullUserName: the user for accessing obkv, which format is `user_name@tenant_name#cluster_name`
3. passWord: the password of user in fullUserName.
4. sysUserName: `root` or `proxy`, which have privileges to access routing system view
5. sysPassWord: the password of sys user in sysUserName.

## Documentation
- English [Coming soon]
- [Simplified Chinese (简体中文)](https://github.com/oceanbase/obkv-table-client-go/wiki/obkv-table-client-go-%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E%E4%B8%8E%E4%BD%BF%E7%94%A8)

## Licencing

obkv-table-client-go is under [MulanPSL - 2.0](http://license.coscl.org.cn/MulanPSL2) licence. You can freely copy and use the source code. When you modify or distribute the source code, please obey the MulanPSL - 2.0 licence.

## Contributing

Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:

- Raise us an [Issue](https://github.com/oceanbase/obkv-table-client-go/issues)
- Submit Pull Requests. For details, see [How to contribute](CONTRIBUTING.md).

## Support

In case you have any problems when using OceanBase Database, welcome reach out for help:

- GitHub Issue [GitHub Issue](https://github.com/oceanbase/obkv-table-client-go/issues)
- Official forum [Official website](https://open.oceanbase.com)
- Knowledge base [Coming soon]