From 147f523833948ecc07a85ed28b2e414b72113b8e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:22 +0800 Subject: [PATCH 001/421] New translations api.md (English) --- website/translated_docs/en-US/api.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/en-US/api.md diff --git a/website/translated_docs/en-US/api.md b/website/translated_docs/en-US/api.md new file mode 100644 index 0000000..0a111da --- /dev/null +++ b/website/translated_docs/en-US/api.md @@ -0,0 +1,5 @@ +--- +id: api +title: '👩🏻‍💻 CovenantSQL API' +--- +## TBD \ No newline at end of file From 8587760d6d3114b02c7e2223b6a6bf82ae70736a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:23 +0800 Subject: [PATCH 002/421] New translations cql.md (English) --- website/translated_docs/en-US/cql.md | 210 +++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 website/translated_docs/en-US/cql.md diff --git a/website/translated_docs/en-US/cql.md b/website/translated_docs/en-US/cql.md new file mode 100644 index 0000000..be990f0 --- /dev/null +++ b/website/translated_docs/en-US/cql.md @@ -0,0 +1,210 @@ +--- +id: cql +title: '🖥️ CQL 命令行工具' +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络, 并将 `cql` 可执行文件保存在 `PATH` 目录。 + +### 配置文件 + +`cql`命令依赖配置文件`config.yaml`和私钥文件`private.key`。这两个文件如果使用`cql generate config`命令生成,会默认放在`~/.cql/`目录下。在此目录下时,`cql`所有子命令的`-config`参数均可以省略不填写。 + +### Master key + +`private.key`文件在生成时需要输入密码,`cql`命令会自动请求输入master key (密码)。 如果想在脚本中使用,可以在子命令后面增加`-password your_master_key`,空密码时用`-no-password`参数。 + +## 查询余额 + +查询余额的命令是:`cql wallet -balance `。其中`token_type`设置为`all`时将返回用户账户中 `Particle` 与 `Wave` 的数量,其他关键词将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +cql wallet -balance Particle -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +cql wallet -balance Bitcoin -config conf/config.yaml +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `cql wallet -balance ` 确定。 + +## 数据库权限管理 + +#### 访问权限 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql grant` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 + +使用新账户给数据库充值: + +```bash +cql transfer -config new_user_config/config.yaml '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +``` + +#### SQL 白名单 + +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 + +增加白名单: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read" + } +} +' +``` + +*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* + +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 + +去掉白名单限制: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read" + } +} +' +# or +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read" +} +' +``` + +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file From 3e6a054d5cdab4614678528a5d40400ec5ef36e7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:24 +0800 Subject: [PATCH 003/421] New translations deployment.md (English) --- website/translated_docs/en-US/deployment.md | 161 ++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 website/translated_docs/en-US/deployment.md diff --git a/website/translated_docs/en-US/deployment.md b/website/translated_docs/en-US/deployment.md new file mode 100644 index 0000000..3ef403b --- /dev/null +++ b/website/translated_docs/en-US/deployment.md @@ -0,0 +1,161 @@ +--- +id: deployment +title: '🐳 Docker 一键部署' +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Observer + +镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 + +(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +#### 在浏览器使用 SQLChain Observer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From 08914eaa5b08d081d8298ba4eee811ec2fc6e143 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:26 +0800 Subject: [PATCH 004/421] New translations intro.md (English) --- website/translated_docs/en-US/intro.md | 72 ++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 website/translated_docs/en-US/intro.md diff --git a/website/translated_docs/en-US/intro.md b/website/translated_docs/en-US/intro.md new file mode 100644 index 0000000..2eab7a1 --- /dev/null +++ b/website/translated_docs/en-US/intro.md @@ -0,0 +1,72 @@ +--- +id: intro +title: CovenantSQL 介绍 +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 1fd855e7eb0a5b04cb1f0ab2a3065caeb9242f06 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:27 +0800 Subject: [PATCH 005/421] New translations native.md (English) --- website/translated_docs/en-US/native.md | 172 ++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 website/translated_docs/en-US/native.md diff --git a/website/translated_docs/en-US/native.md b/website/translated_docs/en-US/native.md new file mode 100644 index 0000000..b76bcc8 --- /dev/null +++ b/website/translated_docs/en-US/native.md @@ -0,0 +1,172 @@ +--- +id: native +title: '📦 CovenantSQL Native SDK' +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 044c3fd8a4f336044b4fc330eabe7f2cb509ccc2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:28 +0800 Subject: [PATCH 006/421] New translations nav.md (English) --- website/translated_docs/en-US/nav.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 website/translated_docs/en-US/nav.md diff --git a/website/translated_docs/en-US/nav.md b/website/translated_docs/en-US/nav.md new file mode 100644 index 0000000..caac5e7 --- /dev/null +++ b/website/translated_docs/en-US/nav.md @@ -0,0 +1,21 @@ +--- +id: nav +title: '📖 使用导航' +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From bb7fd061e4105952f301a5aca3d0e638cc7a4133 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:29 +0800 Subject: [PATCH 007/421] New translations proxy.md (English) --- website/translated_docs/en-US/proxy.md | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 website/translated_docs/en-US/proxy.md diff --git a/website/translated_docs/en-US/proxy.md b/website/translated_docs/en-US/proxy.md new file mode 100644 index 0000000..3a39291 --- /dev/null +++ b/website/translated_docs/en-US/proxy.md @@ -0,0 +1,110 @@ +--- +id: adapter +title: '📦 CovenantSQL Adapter SDK' +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet -listen 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + -config /app/config.yaml -create 1 +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +### NodeJS + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From 83aa829de0438c6040216dfc0b61213f7ff4758d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:30 +0800 Subject: [PATCH 008/421] New translations qna.md (English) --- website/translated_docs/en-US/qna.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/en-US/qna.md diff --git a/website/translated_docs/en-US/qna.md b/website/translated_docs/en-US/qna.md new file mode 100644 index 0000000..c910445 --- /dev/null +++ b/website/translated_docs/en-US/qna.md @@ -0,0 +1,5 @@ +--- +id: qna +title: '🙋 常见问题解答' +--- +## TBD \ No newline at end of file From 4cd50f7003325cdf790a446bae8475edf95ffa56 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:34 +0800 Subject: [PATCH 009/421] New translations quandl.md (English) --- website/translated_docs/en-US/quandl.md | 297 ++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 website/translated_docs/en-US/quandl.md diff --git a/website/translated_docs/en-US/quandl.md b/website/translated_docs/en-US/quandl.md new file mode 100644 index 0000000..886d950 --- /dev/null +++ b/website/translated_docs/en-US/quandl.md @@ -0,0 +1,297 @@ +--- +id: quandl +title: 基于 Quandl 的金融数据分析 +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From edfc5534f469eaa86f298d47c9d2f5794d5e43c9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:36 +0800 Subject: [PATCH 010/421] New translations quickstart.md (English) --- website/translated_docs/en-US/quickstart.md | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 website/translated_docs/en-US/quickstart.md diff --git a/website/translated_docs/en-US/quickstart.md b/website/translated_docs/en-US/quickstart.md new file mode 100644 index 0000000..c2cd203 --- /dev/null +++ b/website/translated_docs/en-US/quickstart.md @@ -0,0 +1,146 @@ +--- +id: quickstart +title: '🌏 TestNet 快速开始' +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.5.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.5.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-minerd` 等, 请将此文件移动到 `PATH` 目录。 + +| 工具名 | 介绍 | +| ---------- | ---------------------------------------------------------------- | +| cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: + +```bash +mkdir conf +wget https://git.io/fhFZe -O conf/config.yaml +wget https://git.io/fhFZv -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +cql create -config conf/config.yaml '{"node":1}' +``` + +在命令行提示中输入master key的密码,之后控制台会输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +cql console -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +在控制台中根据提示输入master key的密码。连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库 SDK + +- [Golang 开发指引](./development) + +## SQLChain 区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +cql generate config +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +cql wallet +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 + +使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): + +```shell +cql wallet -balance all +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 0250ca5811138892dc41139f31204986fcf53dc4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 15:22:37 +0800 Subject: [PATCH 011/421] New translations usecase.md (English) --- website/translated_docs/en-US/usecase.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/en-US/usecase.md diff --git a/website/translated_docs/en-US/usecase.md b/website/translated_docs/en-US/usecase.md new file mode 100644 index 0000000..0ca5313 --- /dev/null +++ b/website/translated_docs/en-US/usecase.md @@ -0,0 +1,5 @@ +--- +id: usecase +title: 使用案例 +--- +## TBD \ No newline at end of file From bfe204e76d69a41eab7458939523e3f1ae40830b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 16:37:34 +0800 Subject: [PATCH 012/421] New translations intro.md (English) --- website/translated_docs/en-US/intro.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/en-US/intro.md b/website/translated_docs/en-US/intro.md index 2eab7a1..e5f0b33 100644 --- a/website/translated_docs/en-US/intro.md +++ b/website/translated_docs/en-US/intro.md @@ -32,13 +32,13 @@ title: CovenantSQL 介绍 alt="Join the chat at https://gitter.im/CovenantSQL/CovenantSQL">

-CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, +CovenantSQL is a GDPR-compliant SQL database running on Open Internet without central coordination. -结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 +Combining the advantages of the blockchain, sharing economy and distributed database, the user's privacy and ownership of data are guaranteed. -CovenantSQL 具备以下特点: +CovenantSQL has the following features: -* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **SQL Interface**: Supports SQL-92 standard, traditional App almost no modifications can be linked to data. * **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 * **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 * **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 From b34e092836cf7622449980dff383aa745f9cfe50 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:11 +0800 Subject: [PATCH 013/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/api.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/zh-CN/api.md diff --git a/website/translated_docs/zh-CN/api.md b/website/translated_docs/zh-CN/api.md new file mode 100644 index 0000000..0a111da --- /dev/null +++ b/website/translated_docs/zh-CN/api.md @@ -0,0 +1,5 @@ +--- +id: api +title: '👩🏻‍💻 CovenantSQL API' +--- +## TBD \ No newline at end of file From a4e0402fed392f5b29517ffe78c1b50dffda22e2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:12 +0800 Subject: [PATCH 014/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 210 +++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql.md diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md new file mode 100644 index 0000000..be990f0 --- /dev/null +++ b/website/translated_docs/zh-CN/cql.md @@ -0,0 +1,210 @@ +--- +id: cql +title: '🖥️ CQL 命令行工具' +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络, 并将 `cql` 可执行文件保存在 `PATH` 目录。 + +### 配置文件 + +`cql`命令依赖配置文件`config.yaml`和私钥文件`private.key`。这两个文件如果使用`cql generate config`命令生成,会默认放在`~/.cql/`目录下。在此目录下时,`cql`所有子命令的`-config`参数均可以省略不填写。 + +### Master key + +`private.key`文件在生成时需要输入密码,`cql`命令会自动请求输入master key (密码)。 如果想在脚本中使用,可以在子命令后面增加`-password your_master_key`,空密码时用`-no-password`参数。 + +## 查询余额 + +查询余额的命令是:`cql wallet -balance `。其中`token_type`设置为`all`时将返回用户账户中 `Particle` 与 `Wave` 的数量,其他关键词将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +cql wallet -balance Particle -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +cql wallet -balance Bitcoin -config conf/config.yaml +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `cql wallet -balance ` 确定。 + +## 数据库权限管理 + +#### 访问权限 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql grant` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 + +使用新账户给数据库充值: + +```bash +cql transfer -config new_user_config/config.yaml '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +``` + +#### SQL 白名单 + +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 + +增加白名单: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read" + } +} +' +``` + +*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* + +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 + +去掉白名单限制: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read" + } +} +' +# or +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read" +} +' +``` + +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file From f31ae69f18d7c4c53fcf7922c9cee63b5d5b65b1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:13 +0800 Subject: [PATCH 015/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/deployment.md | 161 ++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 website/translated_docs/zh-CN/deployment.md diff --git a/website/translated_docs/zh-CN/deployment.md b/website/translated_docs/zh-CN/deployment.md new file mode 100644 index 0000000..3ef403b --- /dev/null +++ b/website/translated_docs/zh-CN/deployment.md @@ -0,0 +1,161 @@ +--- +id: deployment +title: '🐳 Docker 一键部署' +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Observer + +镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 + +(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +#### 在浏览器使用 SQLChain Observer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From fce48b32ed1edcb7db68f7f26e99c55870c83ae1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:15 +0800 Subject: [PATCH 016/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/intro.md | 72 ++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 website/translated_docs/zh-CN/intro.md diff --git a/website/translated_docs/zh-CN/intro.md b/website/translated_docs/zh-CN/intro.md new file mode 100644 index 0000000..2eab7a1 --- /dev/null +++ b/website/translated_docs/zh-CN/intro.md @@ -0,0 +1,72 @@ +--- +id: intro +title: CovenantSQL 介绍 +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From dbd0a414648436bfe5911d035f357c7d9ebc8975 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:16 +0800 Subject: [PATCH 017/421] New translations native.md (Chinese Simplified) --- website/translated_docs/zh-CN/native.md | 172 ++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 website/translated_docs/zh-CN/native.md diff --git a/website/translated_docs/zh-CN/native.md b/website/translated_docs/zh-CN/native.md new file mode 100644 index 0000000..b76bcc8 --- /dev/null +++ b/website/translated_docs/zh-CN/native.md @@ -0,0 +1,172 @@ +--- +id: native +title: '📦 CovenantSQL Native SDK' +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 91541150d885b9afdc01aeae0e84b1ad33a6ffc0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:17 +0800 Subject: [PATCH 018/421] New translations nav.md (Chinese Simplified) --- website/translated_docs/zh-CN/nav.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 website/translated_docs/zh-CN/nav.md diff --git a/website/translated_docs/zh-CN/nav.md b/website/translated_docs/zh-CN/nav.md new file mode 100644 index 0000000..caac5e7 --- /dev/null +++ b/website/translated_docs/zh-CN/nav.md @@ -0,0 +1,21 @@ +--- +id: nav +title: '📖 使用导航' +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From b38092621907718a5cdffa6ae18642178ea8e6a5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:18 +0800 Subject: [PATCH 019/421] New translations proxy.md (Chinese Simplified) --- website/translated_docs/zh-CN/proxy.md | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 website/translated_docs/zh-CN/proxy.md diff --git a/website/translated_docs/zh-CN/proxy.md b/website/translated_docs/zh-CN/proxy.md new file mode 100644 index 0000000..3a39291 --- /dev/null +++ b/website/translated_docs/zh-CN/proxy.md @@ -0,0 +1,110 @@ +--- +id: adapter +title: '📦 CovenantSQL Adapter SDK' +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet -listen 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + -config /app/config.yaml -create 1 +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +### NodeJS + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From b01884228ed0d817a61fe757e62fb82e9afdfe69 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:20 +0800 Subject: [PATCH 020/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/zh-CN/qna.md diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md new file mode 100644 index 0000000..c910445 --- /dev/null +++ b/website/translated_docs/zh-CN/qna.md @@ -0,0 +1,5 @@ +--- +id: qna +title: '🙋 常见问题解答' +--- +## TBD \ No newline at end of file From ccd46b45018cfd10b1432674363415efcbfaf2ee Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:24 +0800 Subject: [PATCH 021/421] New translations quandl.md (Chinese Simplified) --- website/translated_docs/zh-CN/quandl.md | 297 ++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 website/translated_docs/zh-CN/quandl.md diff --git a/website/translated_docs/zh-CN/quandl.md b/website/translated_docs/zh-CN/quandl.md new file mode 100644 index 0000000..886d950 --- /dev/null +++ b/website/translated_docs/zh-CN/quandl.md @@ -0,0 +1,297 @@ +--- +id: quandl +title: 基于 Quandl 的金融数据分析 +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From 7e7f885fd897b1f830c1919c45347c3b3ff94c13 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:25 +0800 Subject: [PATCH 022/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 website/translated_docs/zh-CN/quickstart.md diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md new file mode 100644 index 0000000..c2cd203 --- /dev/null +++ b/website/translated_docs/zh-CN/quickstart.md @@ -0,0 +1,146 @@ +--- +id: quickstart +title: '🌏 TestNet 快速开始' +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.5.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.5.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-minerd` 等, 请将此文件移动到 `PATH` 目录。 + +| 工具名 | 介绍 | +| ---------- | ---------------------------------------------------------------- | +| cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: + +```bash +mkdir conf +wget https://git.io/fhFZe -O conf/config.yaml +wget https://git.io/fhFZv -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +cql create -config conf/config.yaml '{"node":1}' +``` + +在命令行提示中输入master key的密码,之后控制台会输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +cql console -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +在控制台中根据提示输入master key的密码。连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库 SDK + +- [Golang 开发指引](./development) + +## SQLChain 区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +cql generate config +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +cql wallet +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 + +使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): + +```shell +cql wallet -balance all +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 533c71105fe2f4e58d7303264631165550ffca8d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 18:26:26 +0800 Subject: [PATCH 023/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/zh-CN/usecase.md diff --git a/website/translated_docs/zh-CN/usecase.md b/website/translated_docs/zh-CN/usecase.md new file mode 100644 index 0000000..0ca5313 --- /dev/null +++ b/website/translated_docs/zh-CN/usecase.md @@ -0,0 +1,5 @@ +--- +id: usecase +title: 使用案例 +--- +## TBD \ No newline at end of file From 95606b90eeb8fdc67912756e313d67684317ea55 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:39 +0800 Subject: [PATCH 024/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/nav.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/nav.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/nav.md b/website/translated_docs/zh-CN/version-0.3.0/nav.md new file mode 100644 index 0000000..4062dc3 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/nav.md @@ -0,0 +1,22 @@ +--- +id: version-0.3.0-nav +title: '📖 使用导航' +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From fcc8713e66759b5662d8c50cd8d764ad59371719 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:40 +0800 Subject: [PATCH 025/421] New translations proxy.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/proxy.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/proxy.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/proxy.md b/website/translated_docs/zh-CN/version-0.3.0/proxy.md new file mode 100644 index 0000000..836102f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/proxy.md @@ -0,0 +1,111 @@ +--- +id: version-0.3.0-adapter +title: '📦 CovenantSQL Adapter SDK' +original_id: adapter +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet -listen 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + -config /app/config.yaml -create 1 +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +### NodeJS + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From fea103683795d2e65ec4d90174f0aa2b8cbb0745 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:42 +0800 Subject: [PATCH 026/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.3.0/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/api.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/api.md b/website/translated_docs/zh-CN/version-0.3.0/api.md new file mode 100644 index 0000000..05cbbd9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.3.0-api +title: '👩🏻‍💻 CovenantSQL API' +original_id: api +--- +## TBD \ No newline at end of file From f5323656c8a0aa7c2d9c298ee74a057c0880d01f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:43 +0800 Subject: [PATCH 027/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..1f14ac4 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-testnet-zh.md @@ -0,0 +1,96 @@ +--- +id: version-0.3.0-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `~/.cql` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ~/.cql/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额(未加-config参数时,命令会自动找~/.cql目录的config.yaml文件): + +```bash +$ cql -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From 8c26fb5bb8f2a7ed0e24e109af98880115c62905 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:45 +0800 Subject: [PATCH 028/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.3.0/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-zh.md new file mode 100644 index 0000000..4e25cd0 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.3.0-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +* `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +* `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +### SQLChain Observer + +我们在`:11108`端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 7937695b6af680028cc270a444c4a6099d24d611 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:46 +0800 Subject: [PATCH 029/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..17c0215 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.3.0-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 2dc4336e0805a909c4bf22f58cc76604d71728e4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:48 +0800 Subject: [PATCH 030/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..8f38c66 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.3.0-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 7b38ba3a6bbe4f4e79eed5788f2150e3507f57a0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:49 +0800 Subject: [PATCH 031/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/development-golang-client-zh.md new file mode 100644 index 0000000..a7e99e0 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.3.0-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `~/.cql` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +./cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 7408b1f9e0110195766363ffdbf370896623550c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:52 +0800 Subject: [PATCH 032/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/bck/api-json-rpc.md | 442 ++++++++++++++++++ 1 file changed, 442 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.3.0/bck/api-json-rpc.md new file mode 100644 index 0000000..105a705 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/api-json-rpc.md @@ -0,0 +1,442 @@ +--- +id: version-0.3.0-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_shardchains": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + "storage_size": 109870095269 // storage size + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | ---------------------- | ------ | +| 0 | since | integer | since height, excluded | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1024, 1, 10] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "blocks" [ { TODO: block object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 102, + "pages": 11 + } +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO"] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | -------------------- | ------ | +| 0 | since | string | since hash, excluded | "TODO" | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionListOfBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | of block height | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListOfBlock", + "params": [1024, 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO"] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | integer | Create time of the block, unix time in nanoseconds | +| timestamp_human | string | Create time of the block, human readable RFC3339 format | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| address | string | Account address who signed this transaction | +| timestamp | integer | Create time of the transaction, unix time in nanoseconds | +| timestamp_human | string | Create time of the transaction, human readable RFC3339 format | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "type": 1, + "address": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From b96e1eddd08c961789894e537a49a945afbdee71 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:53 +0800 Subject: [PATCH 033/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/guide-zh.md new file mode 100644 index 0000000..324f6d7 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.3.0-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From e815b6827920fc4ec12b66784f1a8ec9cdbf2d57 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:54 +0800 Subject: [PATCH 034/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..b4c5cb4 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.3.0-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From 90f2d2ff1e4f54b6411291d8ee746380407e8ea3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:55 +0800 Subject: [PATCH 035/421] New translations development.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/development.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/development.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/development.md b/website/translated_docs/zh-CN/version-0.3.0/development.md new file mode 100644 index 0000000..0d2c60b --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/development.md @@ -0,0 +1,173 @@ +--- +id: version-0.3.0-development +title: '📦 CovenantSQL SDK' +original_id: development +--- +## Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From ade189a93abff71b9316c6fccca911fb338d840f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:57 +0800 Subject: [PATCH 036/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/cql.md | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/cql.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/cql.md b/website/translated_docs/zh-CN/version-0.3.0/cql.md new file mode 100644 index 0000000..974f5fd --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/cql.md @@ -0,0 +1,150 @@ +--- +id: version-0.3.0-cql +title: '🖥️ CQL 命令行工具' +original_id: cql +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络。 + +## 查询余额 + +查询余额有两个命令:`cql -get-balance` 和 `cql -token-balance `。其中 `-get-balance` 将返回用户账户中 `Particle` 与 `Wave` 的数量,`-token-balance ` 将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +./cql -config conf/config.yaml -token-balance Particle +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +./cql -config conf/config.yaml -token-balance Bitcoin +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql -transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `-get-balance` 或者 `-token-balance ` 确定。 + +## 数据库权限管理 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin`, `Write` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql -update-perm` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 + +使用新账户给数据库充值: + +```bash +./cql -config new_user_config/config.yaml -transfer '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +``` \ No newline at end of file From acb98f12b84ea97967bbc5e4b8ca7a3afb271d21 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:58 +0800 Subject: [PATCH 037/421] New translations native.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/native.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/native.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/native.md b/website/translated_docs/zh-CN/version-0.3.0/native.md new file mode 100644 index 0000000..dfb6829 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/native.md @@ -0,0 +1,173 @@ +--- +id: version-0.3.0-native +title: '📦 CovenantSQL Native SDK' +original_id: native +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 0aee6ac784c14e5426aa9b70ab70e432f9e26eff Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:23:59 +0800 Subject: [PATCH 038/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/deployment.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/deployment.md b/website/translated_docs/zh-CN/version-0.3.0/deployment.md new file mode 100644 index 0000000..d46cdd6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/deployment.md @@ -0,0 +1,162 @@ +--- +id: version-0.3.0-deployment +title: '🐳 Docker 一键部署' +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Observer + +镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 + +(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +#### 在浏览器使用 SQLChain Observer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From 7ccdd56957c5300f20d42562e52fadd363ed9480 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:03 +0800 Subject: [PATCH 039/421] New translations quandl.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/quandl.md | 298 ++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/quandl.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/quandl.md b/website/translated_docs/zh-CN/version-0.3.0/quandl.md new file mode 100644 index 0000000..db94e5f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/quandl.md @@ -0,0 +1,298 @@ +--- +id: version-0.3.0-quandl +title: 基于 Quandl 的金融数据分析 +original_id: quandl +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From 6db4528b4caaed3bc125b4284694059ae7dadb1c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:04 +0800 Subject: [PATCH 040/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.3.0/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/usecase.md b/website/translated_docs/zh-CN/version-0.3.0/usecase.md new file mode 100644 index 0000000..6e7c4ed --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.3.0-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From 2aebdaa40dfff85e432e949717c6cee6a18667e4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:06 +0800 Subject: [PATCH 041/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/quickstart.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/quickstart.md b/website/translated_docs/zh-CN/version-0.3.0/quickstart.md new file mode 100644 index 0000000..6551a16 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/quickstart.md @@ -0,0 +1,148 @@ +--- +id: version-0.3.0-quickstart +title: '🌏 TestNet 快速开始' +original_id: quickstart +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.3.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.3.0/CovenantSQL-v0.3.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.3.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.3.0/CovenantSQL-v0.3.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-utils` 等。 + +| 工具名 | 介绍 | +| ---------- | --------------------------------------------------- | +| cql | CovenantSQL 的客户端,类似 mysql 命令,用于执行 SQL | +| cql-utils | CovenantSQL 工具箱,用于和主链交互 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.3.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) ,或者使用以下命令: + +```bash +mkdir conf +wget https://git.io/fhFZe -O conf/config.yaml +wget https://git.io/fhFZv -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +./cql -config conf/config.yaml -create 1 +``` + +输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +./cql -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库 SDK + +- [Golang 开发指引](./development) + +## SQLChain 区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入你生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为你的钱包充值。有任何问题请来这里讨论:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 7cd687d6c493698d4891472a85ceb0bfcf7b435a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:07 +0800 Subject: [PATCH 042/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.3.0/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/qna.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/qna.md b/website/translated_docs/zh-CN/version-0.3.0/qna.md new file mode 100644 index 0000000..797cb90 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.3.0-qna +title: '🙋 常见问题解答' +original_id: qna +--- +## TBD \ No newline at end of file From dd43fc0d8152ded24004e364584ce598df8c682c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:08 +0800 Subject: [PATCH 043/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.3.0/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.3.0/intro.md diff --git a/website/translated_docs/zh-CN/version-0.3.0/intro.md b/website/translated_docs/zh-CN/version-0.3.0/intro.md new file mode 100644 index 0000000..e698711 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.3.0/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.3.0-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From e8b5356adea025224aaadf45f7b6ca3350c7b7f5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:09 +0800 Subject: [PATCH 044/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase.md b/website/translated_docs/zh-CN/version-0.5.0/usecase.md new file mode 100644 index 0000000..9444a0c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.5.0-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From afda1d28f709b3d0fff04947afd772c5b0567fd1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:11 +0800 Subject: [PATCH 045/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/intro.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/intro.md b/website/translated_docs/zh-CN/version-0.5.0/intro.md new file mode 100644 index 0000000..dd9addc --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.5.0-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From a592a4f2008882b86338086ad24f29a2ceb62045 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:12 +0800 Subject: [PATCH 046/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quickstart.md | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md new file mode 100644 index 0000000..1993893 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -0,0 +1,147 @@ +--- +id: version-0.5.0-quickstart +title: '🌏 TestNet 快速开始' +original_id: quickstart +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.5.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.5.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-minerd` 等, 请将此文件移动到 `PATH` 目录。 + +| 工具名 | 介绍 | +| ---------- | ---------------------------------------------------------------- | +| cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: + +```bash +mkdir conf +wget https://git.io/fhFZe -O conf/config.yaml +wget https://git.io/fhFZv -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +cql create -config conf/config.yaml '{"node":1}' +``` + +在命令行提示中输入master key的密码,之后控制台会输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +cql console -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +在控制台中根据提示输入master key的密码。连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库 SDK + +- [Golang 开发指引](./development) + +## SQLChain 区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +cql generate config +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +cql wallet +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 + +使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): + +```shell +cql wallet -balance all +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 855608e95f35a2f0df1602a3c926ee30eba4d3a6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:13 +0800 Subject: [PATCH 047/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/qna.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md new file mode 100644 index 0000000..ad187f5 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.5.0-qna +title: '🙋 常见问题解答' +original_id: qna +--- +## TBD \ No newline at end of file From 4929f7edb7302ab75f677091bba473ab1df3779c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:16 +0800 Subject: [PATCH 048/421] New translations quandl.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quandl.md | 298 ++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/quandl.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/quandl.md b/website/translated_docs/zh-CN/version-0.5.0/quandl.md new file mode 100644 index 0000000..3608e74 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/quandl.md @@ -0,0 +1,298 @@ +--- +id: version-0.5.0-quandl +title: 基于 Quandl 的金融数据分析 +original_id: quandl +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From abdef87459b9fd1387f169eab462589c534085af Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:18 +0800 Subject: [PATCH 049/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md new file mode 100644 index 0000000..705df6e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -0,0 +1,162 @@ +--- +id: version-0.5.0-deployment +title: '🐳 Docker 一键部署' +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Observer + +镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 + +(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +#### 在浏览器使用 SQLChain Observer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From a24284978aeb1f771dc7f8cee71e48033f1c8b1b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:19 +0800 Subject: [PATCH 050/421] New translations native.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/native.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/native.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/native.md b/website/translated_docs/zh-CN/version-0.5.0/native.md new file mode 100644 index 0000000..031e172 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/native.md @@ -0,0 +1,173 @@ +--- +id: version-0.5.0-native +title: '📦 CovenantSQL Native SDK' +original_id: native +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From a2cf814d270fe5a8768f10e5b1ceb8d043385921 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:21 +0800 Subject: [PATCH 051/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql.md | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md new file mode 100644 index 0000000..0c7c33d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -0,0 +1,211 @@ +--- +id: version-0.5.0-cql +title: '🖥️ CQL 命令行工具' +original_id: cql +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络, 并将 `cql` 可执行文件保存在 `PATH` 目录。 + +### 配置文件 + +`cql`命令依赖配置文件`config.yaml`和私钥文件`private.key`。这两个文件如果使用`cql generate config`命令生成,会默认放在`~/.cql/`目录下。在此目录下时,`cql`所有子命令的`-config`参数均可以省略不填写。 + +### Master key + +`private.key`文件在生成时需要输入密码,`cql`命令会自动请求输入master key (密码)。 如果想在脚本中使用,可以在子命令后面增加`-password your_master_key`,空密码时用`-no-password`参数。 + +## 查询余额 + +查询余额的命令是:`cql wallet -balance `。其中`token_type`设置为`all`时将返回用户账户中 `Particle` 与 `Wave` 的数量,其他关键词将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +cql wallet -balance Particle -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +cql wallet -balance Bitcoin -config conf/config.yaml +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +cql wallet -balance all -config conf/config.yaml +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `cql wallet -balance ` 确定。 + +## 数据库权限管理 + +#### 访问权限 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql grant` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 + +使用新账户给数据库充值: + +```bash +cql transfer -config new_user_config/config.yaml '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +``` + +#### SQL 白名单 + +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 + +增加白名单: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read" + } +} +' +``` + +*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* + +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 + +去掉白名单限制: + +```shell +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read" + } +} +' +# or +cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read" +} +' +``` + +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file From 38dd865587e9f5a9fc2f983205bb58cb8e6227cd Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:22 +0800 Subject: [PATCH 052/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/nav.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/nav.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/nav.md b/website/translated_docs/zh-CN/version-0.5.0/nav.md new file mode 100644 index 0000000..8597bac --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/nav.md @@ -0,0 +1,22 @@ +--- +id: version-0.5.0-nav +title: '📖 使用导航' +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From bbce0b22d6df46dd23dea1e44a103dab8331a022 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:23 +0800 Subject: [PATCH 053/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/api.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/api.md b/website/translated_docs/zh-CN/version-0.5.0/api.md new file mode 100644 index 0000000..bcd93df --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.5.0-api +title: '👩🏻‍💻 CovenantSQL API' +original_id: api +--- +## TBD \ No newline at end of file From 4a172c699bf625954b8fed1fd559a69da59ba3fa Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:25 +0800 Subject: [PATCH 054/421] New translations development.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/development.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/development.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/development.md b/website/translated_docs/zh-CN/version-0.1.0/development.md new file mode 100644 index 0000000..1b4a728 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/development.md @@ -0,0 +1,173 @@ +--- +id: version-0.1.0-development +title: '📦 CovenantSQL SDK' +original_id: development +--- +## Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 63b1d80150f7f69578dcbbd7d7e42f5c2ba44c7f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:27 +0800 Subject: [PATCH 055/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..2877e82 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-testnet-zh.md @@ -0,0 +1,93 @@ +--- +id: version-0.1.0-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +运行完成后,`cql-utils`会在 `./conf` 目录生成一个配置文件。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `./conf` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ./conf/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -config conf/config.yaml -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From 98d162dc41b5a397c2ee6e9607f4209aec893ef6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:28 +0800 Subject: [PATCH 056/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.1.0/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-zh.md new file mode 100644 index 0000000..8eebf58 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.1.0-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +* `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +* `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 695ef80082360819ee9e1147e539c826f61b8656 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:29 +0800 Subject: [PATCH 057/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..767df8d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.1.0-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 79cb6b39f6c9ccf575298b5b1dedbd128d6c34da Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:31 +0800 Subject: [PATCH 058/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..f240f32 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.1.0-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From cae8d486516c6ec74049a38bd003b29269595445 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:32 +0800 Subject: [PATCH 059/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..b46fae0 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.1.0-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From bc20a6ad12a827bbe2342b6f209e4d16efaf0bc5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:34 +0800 Subject: [PATCH 060/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/development-golang-client-zh.md new file mode 100644 index 0000000..9bbb203 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.1.0-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `conf` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +$ cql-utils -tool confgen -root conf +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 8d73aaffc5005b9d211e14a7098bfd25c5843faf Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:36 +0800 Subject: [PATCH 061/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/bck/api-json-rpc.md | 440 ++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.1.0/bck/api-json-rpc.md new file mode 100644 index 0000000..7dfc832 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/api-json-rpc.md @@ -0,0 +1,440 @@ +--- +id: version-0.1.0-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_databases": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------- | ---------------------- | ------ | +| 0 | from | integer | start height, included | 1 | +| 1 | to | integer | end height, excluded | 11 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1, 11] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: block object } + ] +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1, true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO", true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | --------- | ------- | ------------------------------------------- | ---------- | +| 0 | since | string | hash as the start point of traverse | "TODO" | +| 1 | direction | string | traverse direction, "backward" or "forward" | "backward" | +| 2 | size | integer | page size, [5, 100] | 20 | + + QhcAe42Xf8cwGUf5NYGQDQ + XNZ9yipFBUV5ySBtreW1MA ↑ forward (in newer blocks) + 9fXd3s5HE5fC8lOYY6uAZA + KhytGjS0xjw5CJvcJYpsNg ← since (paging mark) + 2KOxrKMS4iVDKXnm6HuYiA + 71VwqOMOvAsBXJRMeBruWg ↓ backward (in older blocks) + 0P3k04RKHw8SEMKHxADC8A + + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", "forward", 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionListInBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | --------------------- | ------ | +| 0 | height | integer | block height | 1024 | +| 1 | from | integer | start index, included | 0 | +| 2 | to | integer | end index, excluded | 10 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListInBlock", + "params": [1024, 0, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO", true] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| ----------- | ------- | -------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | string | Create time of the block | +| signee | string | Public key of the node who signed this block | +| signature | string | Signature for the this block | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "signee": "TODO", + "signature": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| ------------ | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| signee | string | Public key of the account who signed this transaction | +| address | string | Account address who signed this transaction | +| signature | string | Signature of this transaction | +| timestamp | string | Create time of the transaction | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "type": 1, + "signee": "TODO", + "address": "TODO", + "signature": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From 77be26d9812a495738fa370a22098f851eb19e19 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:37 +0800 Subject: [PATCH 062/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.1.0/bck/guide-zh.md new file mode 100644 index 0000000..98858f8 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.1.0-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 015d27db4f903afecbccb3371ed4ae6c7096e7ff Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:38 +0800 Subject: [PATCH 063/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md new file mode 100644 index 0000000..444aba4 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.5.0-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 924fd8e346142398f6e227ce60ceba8770a86d59 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:40 +0800 Subject: [PATCH 064/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.1.0/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/qna.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/qna.md b/website/translated_docs/zh-CN/version-0.1.0/qna.md new file mode 100644 index 0000000..8c0e5d4 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.1.0-qna +title: '🙋 常见问题解答' +original_id: qna +--- +## TBD \ No newline at end of file From 3d53108c7eb8587309549409c2876f64925d5e99 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:41 +0800 Subject: [PATCH 065/421] New translations proxy.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/proxy.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/proxy.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/proxy.md b/website/translated_docs/zh-CN/version-0.5.0/proxy.md new file mode 100644 index 0000000..254b24b --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/proxy.md @@ -0,0 +1,111 @@ +--- +id: version-0.5.0-adapter +title: '📦 CovenantSQL Adapter SDK' +original_id: adapter +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet -listen 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + -config /app/config.yaml -create 1 +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +### NodeJS + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From 776ee52d41d3dfd2a50754e98e95b46e387de10e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:42 +0800 Subject: [PATCH 066/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/intro.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/intro.md b/website/translated_docs/zh-CN/version-0.2.0/intro.md new file mode 100644 index 0000000..7fd16c7 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.2.0-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 8d93b3f63b6e7ba1478893ff514a3c711645e51e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:44 +0800 Subject: [PATCH 067/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/api-json-rpc.md | 442 ++++++++++++++++++ 1 file changed, 442 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md new file mode 100644 index 0000000..1038b09 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md @@ -0,0 +1,442 @@ +--- +id: version-0.5.0-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_shardchains": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + "storage_size": 109870095269 // storage size + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | ---------------------- | ------ | +| 0 | since | integer | since height, excluded | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1024, 1, 10] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "blocks" [ { TODO: block object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 102, + "pages": 11 + } +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO"] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | -------------------- | ------ | +| 0 | since | string | since hash, excluded | "TODO" | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionListOfBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | of block height | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListOfBlock", + "params": [1024, 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO"] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | integer | Create time of the block, unix time in nanoseconds | +| timestamp_human | string | Create time of the block, human readable RFC3339 format | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| address | string | Account address who signed this transaction | +| timestamp | integer | Create time of the transaction, unix time in nanoseconds | +| timestamp_human | string | Create time of the transaction, human readable RFC3339 format | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "type": 1, + "address": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From 8fd7b073c09d1e7e4f28033fd1c4dac7ec210b3b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:46 +0800 Subject: [PATCH 068/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/deployment.md | 198 ++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/deployment.md b/website/translated_docs/zh-CN/version-0.2.0/deployment.md new file mode 100644 index 0000000..7cb985e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/deployment.md @@ -0,0 +1,198 @@ +--- +id: version-0.2.0-deployment +title: '🐳 Docker 一键部署' +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Explorer + +由于读数据库需要计费,并且数据库有权限限制,在启动 Explorer 前需要确保 Explorer 使用的钱包地址内有充足的 token 并且已使用管理员账户为 Explorer 地址授权读权限。(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +**注意:**在授权前不要在浏览器打开 Explorer 地址。 + +获得转账地址: + +```bash +docker exec -it covenantsql_observer /app/cql-utils -tool addrgen -private /app/node_observer/private.key +``` + +输出: + +```bash +Enter master key(press Enter for default: ""): + +wallet address: 6304a1bcc4a8903b1bc8675fd37a588040a55ade1f1df552ef7721a823ae1c25 +``` + +转账: + +```bash +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -transfer '{"addr":"6304a1bcc4a8903b1bc8675fd37a588040a55ade1f1df552ef7721a823ae1c25","amount":"100000000 Particle"}' +``` + +其中,`addr` 表示转账地址,这里为 Explorer 使用的钱包地址,Explorer 地址可以在上一步中获得。`amount` 为能使 Explorer 运行的最小金额 `gas_price*number_of_miner*240000`,建议多一转些方便后续操作。 + +授权: + +```bash +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -update-perm '{"chain":"139f71bb7b2775baafa42bd9ed2ade6755381d4eed1e02d4847eb1491847a0ce","user":"6304a1bcc4a8903b1bc8675fd37a588040a55ade1f1df552ef7721a823ae1c25","perm":"Read"}' +``` + +充值: + +```bash +docker exec -it covenantsql_observer /app/cql -config /app/node_observer/config.yaml -transfer '{"addr":"139f71bb7b2775baafa42bd9ed2ade6755381d4eed1e02d4847eb1491847a0ce","amount":"90000000 Particle"}' +``` + +关于转账充值与授权的详细说明请参考[文档](cql.md)。 + +### 在浏览器使用 SQLChain Explorer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From 64172212bcac32d49a41c6841f1fc8958f14d3c7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:47 +0800 Subject: [PATCH 069/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.2.0/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-zh.md new file mode 100644 index 0000000..d6e2e01 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.2.0-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +* `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +* `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 26295d0a8de5e994b612344b946cb546948f4d06 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:48 +0800 Subject: [PATCH 070/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..fa97a30 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.2.0-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 5fcfd9f27d60af6bd66cd0840ed057daad981df3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:50 +0800 Subject: [PATCH 071/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..eb66866 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.2.0-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From fe4fd52e76d068ef07a545750eb8adaddd9fa9c4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:51 +0800 Subject: [PATCH 072/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..d06e552 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.2.0-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From dac4295558c52d40fe446273e35f05211f9c2b40 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:53 +0800 Subject: [PATCH 073/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/development-golang-client-zh.md new file mode 100644 index 0000000..0fd9b7a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.2.0-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `conf` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +$ cql-utils -tool confgen -root conf +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 37fd50180dbf4fea8f0af2bb9e4764f4d6f229cb Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:55 +0800 Subject: [PATCH 074/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/bck/api-json-rpc.md | 441 ++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.2.0/bck/api-json-rpc.md new file mode 100644 index 0000000..68689c2 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/api-json-rpc.md @@ -0,0 +1,441 @@ +--- +id: version-0.2.0-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_databases": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | ---------------------- | ------ | +| 0 | since | integer | since height, excluded | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1024, 1, 10] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "blocks" [ { TODO: block object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 102, + "pages": 11 + } +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO"] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | -------------------- | ------ | +| 0 | since | string | since hash, excluded | "TODO" | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionListOfBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | of block height | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListOfBlock", + "params": [1024, 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO"] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | integer | Create time of the block, unix time in nanoseconds | +| timestamp_human | string | Create time of the block, human readable RFC3339 format | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| address | string | Account address who signed this transaction | +| timestamp | integer | Create time of the transaction, unix time in nanoseconds | +| timestamp_human | string | Create time of the transaction, human readable RFC3339 format | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "type": 1, + "address": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From 45e6751ed52be2b9429c8823a7bee1bdb13236b4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:56 +0800 Subject: [PATCH 075/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/guide-zh.md new file mode 100644 index 0000000..659ef89 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.2.0-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 169fc2f72a65f692c528f10ea864678c9aa96e39 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:57 +0800 Subject: [PATCH 076/421] New translations development.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/development.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/development.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/development.md b/website/translated_docs/zh-CN/version-0.2.0/development.md new file mode 100644 index 0000000..ecad5dd --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/development.md @@ -0,0 +1,173 @@ +--- +id: version-0.2.0-development +title: '📦 CovenantSQL SDK' +original_id: development +--- +## Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 60e6fc82b7d5e79f41d60c875befd80b25c54400 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:24:58 +0800 Subject: [PATCH 077/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.2.0/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/qna.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/qna.md b/website/translated_docs/zh-CN/version-0.2.0/qna.md new file mode 100644 index 0000000..f07b2ca --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.2.0-qna +title: '🙋 常见问题解答' +original_id: qna +--- +## TBD \ No newline at end of file From bdbbeaaf70785e1f20f186d36464358e3a6d68d2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:00 +0800 Subject: [PATCH 078/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/cql.md | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/cql.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/cql.md b/website/translated_docs/zh-CN/version-0.2.0/cql.md new file mode 100644 index 0000000..b46e6d4 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/cql.md @@ -0,0 +1,144 @@ +--- +id: version-0.2.0-cql +title: '🖥️ CQL 命令行工具' +original_id: cql +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络。 + +## 查询余额 + +查询余额有两个命令:`cql -get-balance` 和 `cql -token-balance `。其中 `-get-balance` 将返回用户账户中 `Particle` 与 `Wave` 的数量,`-token-balance ` 将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +./cql -config conf/config.yaml -token-balance Particle +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +./cql -config conf/config.yaml -token-balance Bitcoin +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql -transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `-get-balance` 或者 `-token-balance ` 确定。 + +## 数据库权限管理 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin`, `Write` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql -update-perm` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 \ No newline at end of file From 9adf3c404995e8d50c961a55a027eedbccc45ba4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:03 +0800 Subject: [PATCH 079/421] New translations quandl.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/quandl.md | 228 ++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/quandl.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/quandl.md b/website/translated_docs/zh-CN/version-0.2.0/quandl.md new file mode 100644 index 0000000..5363f5f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/quandl.md @@ -0,0 +1,228 @@ +--- +id: version-0.2.0-quandl +title: 基于 Quandl 的金融数据分析 +original_id: quandl +--- +## 关于Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必limit小于10万,因为全表数据量过大) + +使用时,请使用where语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下SQL命令行: + + select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000 + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从1960到1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000 + +3. 注意:如果内容整列为null的,属于表结构本身不存在的字段,可以自行去除。 + +## 附件表 + +| database_code | description | | +| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | +| BUNDESBANK | Data on the German economy, money and capital markets, public finances, banking, households, Euro-area aggregates, trade and external debt. | 德意志联邦银行数据仓库 | +| URC | Advance and decline data for the NYSE, AMEX, and NASDAQ stock exchanges. From various publicly-available sources and the median value is reported. | 独角兽研究公司数据 | +| DCE | Agriculture and commodities futures from DCE, with history spanning almost a decade for select futures. | 大连商品交易所数据 | +| WFC | This database offers mortgage purchase and refinance rates from Wells Fargo Home Mortgage, a division of Wells Fargo Bank. | 富国银行住房抵押贷款数据 | +| USDAFNS | Food and Nutrition Service administrates federal nutrition assistance programs for low-income households and children. Data on costs and participation rates. | 美国农业部食品与营养服务项目数据 | +| LJUBSE | This database contains the Ljubljana Stock Exchange indexes and is based in Ljubljana, Slovenia. | 卢布尔雅那证券交易所数据 | +| TOCOM | Agriculture and commodities futures from Tokyo Commodities Exchange (TOCOM), with history spanning almost a decade for select futures. | 东京商品交易所数据 | +| LBMA | An international trade association in the London gold and silver market, consisting of central banks, private investors, producers, refiners, and other agents. | 伦敦金银市场协会数据 | +| WCSC | This database is designed to provide a strategic overview of the World Bank Group’s performance toward ending extreme poverty and promoting shared prosperity. | 世界银行企业积分卡数据 | +| CMHC | The CMHC is a gov’t-owned corporation that provides affordable housing to Canadian citizens and collects data such as prices, construction, and supply. | 加拿大住房抵押贷款公司 | +| WGEC | Data containing commodity prices and indices from 1960 to present. | 世界银行全球经济监测商品数据(GEM) | +| FED | Official US figures on money supply, interest rates, mortgages, government finances, bank assets and debt, exchange rates, industrial production. | 美联储数据公布 | +| WPSD | Data jointly developed by the World Bank and the International Monetary Fund, which brings together detailed public sector government debt data. | 世界银行公共部分支出数据 | +| UGID | This database offers a wide range of global indicators, covering population, public health, employment, trade, education, inflation and external debt. | 联合国全球指标 | +| RBA | Central bank and monetary authority, regulates banking industry, sets interest rates, and services government's debt. Data on key economic indicators. | 澳大利亚储备银行数据 | +| UCOM | This database offers comprehensive global data on imports and exports of commodities such as food, live animals, pharmaceuticals, metals, fuels and machinery. | 联合国商品贸易数据 | +| SIDC | The SIDC hosts data spanning from the 1700's on solar activity, specifically sunspot activity. | 太阳影响数据分析中心数据 | +| ZCE | Agriculture and commodities futures from ZCE, with history spanning almost a decade for select futures. | 郑州商品交易所数据 | +| ZILLOW2 | Home prices and rents by size, type and tier; housing supply, demand and sales; sliced by zip code, neighbourhood, city, metro area, county and state. | Zillow房地产研究 | +| USTREASURY | The U.S. Treasury ensures the nation's financial security, manages the nation's debt, collects tax revenues, and issues currency, provides data on yield rates. | 美国财政部数据 | +| BTS | BTS provides information on transportation systems in the United States. Their non-multimodal department provides statistics on air travel. | 美国交通运输统计局数据 | +| USDAFAS | The USDA Foreign Agricultural Service connects U.S. agriculture with the world markets. It provides statistics on production and exports in foreign countries. | 美国农业部外国农业服务数据(FAS) | +| OECD | International organization of developed countries that promotes economic welfare. Collects data from members and others to make policy recommendations. | 世界经济合作与发展组织数据 | +| OPEC | International organization and economic cartel overseeing policies of oil-producers, such as Iraq, Iran, Saudi Arabia, and Venezuela. Data on oil prices. | 欧佩克数据 | +| MCX | India's largest commodity exchange servicing futures trading in metals, energy, and agriculture. World's 3rd largest exchange in contracts and trading volume. | 印度多种商品交易所数据 | +| ECONOMIST | The Big Mac index was invented by The Economist in 1986 as a lighthearted guide to whether currencies are at their “correct” level. It is based on the theory of purchasing-power parity (PPP). | 经济学人 - 巨无霸指数 | +| NSDL | Depository in India responsible for economic development of the country that has established a national infrastructure of international standards that handles most of the securities held and settled in dematerialised form in the Indian capital market. | 国家证券存管有限公司(印度)数据 | +| FRED | Growth, employment, inflation, labor, manufacturing and other US economic statistics from the research department of the Federal Reserve Bank of St. Louis. | 美联储经济数据 | +| GDT | | 全球乳品贸易数据 | +| CFFEX | Index and bond futures from CFFEX, with history spanning almost a decade for select futures. | 中国金融期货交易所数据 | +| CITYPOP | Thomas Brinkhoff provides population data for cities and administrative areas in most countries. | Thomas Brinkhoff的城市人口数据 | +| BCHARTS | Exchange rates for bitcoin against a large number of currencies, from all major bitcoin exchanges, including current and historical exchange rates. | 比特币图表汇率数据 | +| LOCALBTC | | Local Bitcoins数据 | +| JODI | JODI oil and gas data comes from over 100 countries consisting of multiple energy products and flows in various methods of measurement. | JODI石油世界数据库 | +| UENG | This database offers comprehensive global statistics on production, trade, conversion, and final consumption of new and renewable energy sources. | 联合国能源统计数据 | +| ULMI | This database offers comprehensive youth unemployment figures broken up by gender for all countries in the world. | 联合国劳工市场指标 | +| MAURITIUSSE | Stock Exchange of Mauritius indices data. | 毛里求斯证券交易所数据 | +| UKRSE | UKRSE presents the most current available data related to the largest stock exchanges in Ukraine. The exchange is located in Kiev and accounts for roughly three-quarters of Ukraine's total equity trading volume | 乌克兰交易所数据 | +| BITSTAMP | Bitstamp is a trading platform for Bitcoin. | Bitstamp数据 | +| UNAE | This database offers global data on gross domestic product, gross national income, and gross value added by different sectors for all countries in the world. | 联合国国民账户估算数据 | +| UNAC | This database offers global data on national accounts, such as assets and liabilities of households, corporations and governments. | 联合国国民账户官方国家数据 | +| UTOR | This database offers comprehensive data on international tourism. Data includes number of tourist arrivals and tourism expenditures for all countries. | 联合国世界旅游业数据 | +| WFE | A trade association of sixty publicly regulated stock, futures, and options exchanges that publishes data for its exchanges, like market capitalization. | 世界交易所联合会数据 | +| FRBC | The Federal Reserve Bank of Cleveland collects data from hundreds of financial institutions, including depository institutions, bank holding companies, and other entities that is used to assess financial institution conditions and also to glean insights into how the economy and financial system are doing. | 克利夫兰联邦储备银行数据 | +| UGEN | This database offers comprehensive global data on a wide range of gender-related indicators, covering demography, health, education and employment. | 联合国性别信息 | +| BITFINEX | Bitfinex is a trading platform for Bitcoin, Litecoin and Darkcoin with many advanced features including margin trading, exchange and peer to peer margin funding. | Bitfinex数据 | +| UGHG | This database offers comprehensive global data on anthropogenic emissions of the six principal greenhouse gases. Data goes back to 1990. | 联合国温室气体清单 | +| UIST | This database offers global data on industrial development indicators, including output, employees, wages, value added for a wide range of industries. | 联合国工业发展组织数据 | +| PRAGUESE | Price index data from the Prague Stock Exchange. | 布拉格证券交易所数据 | +| PFTS | Index data from the PFTS Stock Exchange, the largest marketplace in Ukraine. | PFTS证券交易所(乌克兰)数据 | +| WARSAWSE | WIG20 index has been calculated since April 16, 1994 based on the value of portfolio with shares in 20 major and most liquid companies in the WSE Main List. | 华沙证券交易所数据 | +| TUNISSE | The main reference index of Tunis Stock Exchange. | 突尼斯证券交易所数据 | +| FRKC | FRKC is the regional central bank for the 10th District of the Federal Reserve, publishing data on banking in mostly agricultural transactions. | 堪萨斯城联邦储备银行数据 | +| UENV | This database offers global data on water and waste related indicators, including fresh water supply and precipitation, and generation and collection of waste. | 联合国环境统计数据 | +| NSE | Stock and index data from the National Stock Exchange of India. | 印度国家证券交易所数据 | +| UFAO | This database offers global food and agricultural data, covering crop production, fertilizer consumption, use of land for agriculture, and livestock. | 联合国粮食和农业数据 | +| TAIFEX | Index and bond futures from TAIFEX, with history spanning over a decade for select futures. | 台湾期货交易所数据 | +| GDAX | GDAX is the world’s most popular place to buy and sell bitcoin. | GDAX(全球数字资产交易所)数据 | +| ARES | ARES protects investors, contributes to development of the real estate securitization product market, and facilitates expansion of the real estate investment market. | 房地产证券化协会数据 | +| SHADOWS | This dataset contains the three major indicators from the Wu-Xia papers which serve to identify the shadow rates on all three major banks. | 影子联邦基金利率模型数据 | +| NAAIM | The NAAIM Exposure Index represents the average exposure to US Equity markets reported by NAAIM members. | 全国积极投资管理者协会头寸指数 | +| CBRT | CBRT is responsible for taking measures to sustain the stability of the financial system in Turkey. | 土耳其共和国中央银行数据 | +| CEGH | No description for this database yet. | 中欧天然气中心数据 | +| FINRA | Financial Industry Regulatory Authority provides short interest data on securities firms and exchange markets. | 美国金融业监管局数据 | +| NASDAQOMX | Over 35,000 global indexes published by NASDAQ OMX including Global Equity, Fixed Income, Dividend, Green, Nordic, Sharia and more. Daily data. | 纳斯达克OMX全球指数数据 | +| EURONEXT | Historical stock data from Euronext, the largest European exchange. | 泛欧证券交易所数据 | +| UICT | This database offers comprehensive global data on information and communication technology, including telephone, cellular and internet usage for all countries. | 联合国信息和通信技术数据 | +| USAID | US Agency for International Development provides a complete historical record of all foreign assistance provided by the United States to the rest of the world. | 美国国际开发署数据 | +| ZAGREBSE | Croatia's only stock exchange. It publishes data on the performance of its stock and bond indexes. | 萨格勒布证券交易所数据 | +| QUITOSE | The indexes of the national Stock Exchange of Ecuador. | 基多证券交易所(厄瓜多尔)数据 | +| ECBCS | Data in this database is derived from harmonized surveys for different sectors of the economies in the European Union (EU) and in the EU applicant countries. | 欧盟委员会商业和消费者调查 | +| PSE | This database describes the distribution of top incomes in a growing number of countries. Numbers are derived using tax data. | 巴黎经济学院数据 | +| MALTASE | The Malta Stock Exchange carries out the role of providing a structure for admission of financial instruments to its recognised lists which may subsequently be traded on a regulated, transparent and orderly market place (secondary market).The main participants in the market are Issuers, Stock Exchange Members (stockbrokers), and the investors in general. | 马耳他证券交易所数据 | +| GPP | No description for this database yet. | 全球石油价格 | +| PPE | No description for this database yet. | 波兰电力交易所(TGE)数据 | +| UKONS | Data on employment, investment, housing, household expenditure, national accounts, and many other socioeconomic indicators in the United Kingdom. | 英国国家统计局数据 | +| NCDEX | A professionally managed on-line multi-commodity exchange in India | 国家商品及衍生品交易所(印度)数据 | +| WSE | No description for this database yet. | 华沙证券交易所(GPW)数据 | +| TFX | The Tokyo Financial Exchange is a futures exchange that primary deals in financial instruments markets that handle securities and market derivatives. | 东京金融交易所数据 | +| WGFD | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | 世界银行全球金融发展数据 | +| CEPEA | CEPEA is an economic research center at the University of Sao Paulo focusing on agribusiness issues, publishing price indices for commodities in Brazil. | 应用经济学应用研究中心(巴西)数据 | +| SBJ | A Japanese government statistical agency that provides statistics related to employment and the labour force. | 日本统计局数据 | +| WGEM | Data on global economic developments, with coverage of high-income, as well as developing countries. | 世界银行全球经济监测 | +| WGDF | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | 世界银行全球发展金融 | +| WWDI | Most current and accurate development indicators, compiled from officially-recognized international sources. | 世界银行世界发展指标 | +| WESV | Company-level private sector data, covering business topics including finance, corruption, infrastructure, crime, competition, and performance measures. | 世界银行企业调查 | +| CHRIS | Continuous contracts for all 600 futures on Quandl. Built on top of raw data from CME, ICE, LIFFE etc. Curated by the Quandl community. 50 years history. | 维基连续期货 | +| WDBU | Data on business regulations and their enforcement for member countries and selected cities at the subnational and regional level. | 世界银行存续商业数据 | +| OSE | The second largest securities exchange in Japan. Unlike the TSE, OSE is strongest in derivatives trading, the majority of futures and options in Japan. | 大阪证券交易所数据 | +| RFSS | The Russian governmental statistical agency that publishes social, economic, and demographic statistics for Russia at the national and local levels. | 俄罗斯联邦统计局数据 | +| EUREX | Index, rate, agriculture and energy futures from EUREX, Europe's largest futures exchange, with history spanning a decade for select futures. | 欧洲期货交易所数据 | +| WMDG | Data drawn from the World Development Indicators, reorganized according to the goals and targets of the Millennium Development Goals (MDGs). | 世界银行千年发展目标数据 | +| ZILLOW | Home prices and rents by size, type and tier; housing supply, demand and sales; sliced by zip code, neighbourhood, city, metro area, county and state. | Zillow房地产研究 | +| WPOV | Indicators on poverty headcount ratio, poverty gap, and number of poor at both international and national poverty lines. | 世界银行贫困统计 | +| EUREKA | A research company focused on hedge funds and other alternative investment funds. It publishes data on the performances of hedge funds. | Eurekahedge数据 | +| MOFJ | Japanese government bond interest rate data, published daily by the Ministry of Finance. | 日本财务省数据 | +| PIKETTY | Data on Income and Wealth from "Capital in the 21st Century", Harvard University Press 2014. | Thomas Piketty数据 | +| PSX | Daily closing stock prices from the Pakistan Stock Exchange. | 巴基斯坦证交所数据 | +| SGX | Asian securities and derivatives exchange that trades in equities for many large Singaporean and other Asian companies. Listed on its own exchange. | 新加坡交易所数据 | +| UIFS | This database offers comprehensive data on international financial indicators, such as average earnings, bond yields, government revenues and expenditures. | 联合国国际金融统计 | +| UINC | This database offers global data on production of industrial commodities, such as ores and minerals, food products, transportable goods, and metal products. | 联合国工业商品数据 | +| INSEE | INSEE is the national statistical agency of France. It collects data on France's economy and society, such as socioeconomic indicators and national accounts. | 国家统计和经济研究所(法国)数据 | +| SNB | Central bank responsible for monetary policy and currency. Data on international accounts, interest rates, money supply, and other macroeconomic indicators. | 瑞士国家银行数据 | +| ODE | A non-profit commodity exchange in the Kansai region of Japan that trades in seven key agricultural commodities. | 大阪道岛商品交易所数据 | +| WGEN | Data describing gender differences in earnings, types of jobs, sectors of work, farmer productivity, and entrepreneurs’ firm sizes and profits. | 世界银行性别统计 | +| WHNP | Key health, nutrition and population statistics. | 世界银行健康营养与人口统计 | +| WIDA | Data on progress on aggregate outcomes for IDA (International Development Association) countries for selected indicators. | 世界银行国际发展协会 | +| ECMCI | Updated monthly, this database provides monetary conditions index values in the Euro zone. History goes back to 1999. | 欧盟委员会货币状况指数 | +| NBSC | Statistics of China relating to finance, industry, trade, agriculture, real estate, and transportation. | 中国国家统计局数据 | +| MAS | No description for this database yet. | 新加坡金融管理局数据 | +| MGEX | A marketplace of futures and options contracts for regional commodities that facilitates trade of agricultural indexes. | 明尼阿波利斯谷物交易所数据 | +| WWGI | Data on aggregate and individual governance indicators for six dimensions of governance. | 世界银行全球治理指标 | +| ISM | ISM promotes supply-chain management practices and publishes data on production and supply chains, new orders, inventories, and capital expenditures. | 供应管理研究所 | +| PERTH | The Perth Mint’s highs, lows and averages of interest rates and commodities prices, updated on a monthly basis. | 珀斯铸币厂数据 | +| UKR | No description for this database yet. | 乌克兰交易所数据 | +| FRBNY | The FRBNY is the largest regional central bank in the US. Sets monetary policy for New York, most of Connecticut and New Jersey, and some territories. | 纽约联邦储备银行数据 | +| FRBP | The FRBP is a regional central bank for the Federal Reserve. It publishes data on business confidence indexes, GDP, consumption, and other economic indicators. | 费城联邦储备银行数据 | +| FMSTREAS | The monthly receipts/outlays and deficit/surplus of the United States of America. | 美国财政部 - 财务管理处数据 | +| EIA | US national and state data on production, consumption and other indicators on all major energy products, such as electricity, coal, natural gas and petroleum. | 美国能源信息管理局数据 | +| SOCSEC | Provides data on the US social security program, particularly demographics of beneficiaries; disabled, elderly, and survivors. | 美国社会保障局数据 | +| TFGRAIN | Cash price of corn and soybeans including basis to front month futures contract. | 顶级飞行谷物合作社数据 | +| IRPR | Puerto Rico Institute of Statistics statistics on manufacturing. | 波多黎各统计研究所数据 | +| BCHAIN | Blockchain is a website that publishes data related to Bitcoin, updated daily. | blockchain.com数据 | +| BITCOINWATCH | Bitcoin mining statistics. | Bitcoin Watch数据 | +| ODA | IMF primary commodity prices and world economic outlook data, published by Open Data for Africa. Excellent cross-country macroeconomic data. | 国际货币基金组织跨国宏观经济统计 | +| WADI | A collection of development indicators on Africa, including national, regional and global estimates. | 世界银行非洲发展指标 | +| WEDU | Internationally comparable indicators on education access, progression, completion, literacy, teachers, population, and expenditures. | 世界银行教育统计 | +| WGLF | Indicators of financial inclusion measures on how people save, borrow, make payments and manage risk. | 世界银行全球Findex(全球金融包容性数据库) | +| WWID | The World Wealth and Income Database aims to provide open and convenient access to the most extensive available database on the historical evolution of the world distribution of income and wealth, both within countries and between countries. | 世界财富和收入数据库 | +| BTER | Historical exchange rate data for crypto currencies. | 比特儿数据 | +| BP | BP is a large energy producer and distributor. It provides data on energy production and consumption in individual countries and larger subregions. | BP能源生产和消费数据 | +| AMFI | This database represents fund information from The Association of Mutual Funds in India. | 印度共同基金协会数据 | +| BOC | Economic, financial and banking data for Canada. Includes interest rates, inflation, national accounts and more. Daily updates. | 加拿大银行统计数据库 | +| BLSE | US national and state-level employment and unemployment statistics, published by the Bureau of Labor Statistics. | 美国劳工统计局就业与失业统计 | +| BLSI | US national and state-level inflation data, published by the Bureau of Labor Statistics. | 美国劳工统计局通货膨胀和价格统计 | +| BITAL | This database provides data on stock future contracts from the Borsa Italiana, now part of London Stock Exchange Group. | 意大利证交所数据 | +| BLSB | US work stoppage statistics, published by the Bureau of Labor Statistics. | 美国劳工统计局薪酬福利统计 | +| ECB | The central bank for the European Union oversees monetary policy and the Euro, and provides data on related macroeconomic variables. | 欧洲中央银行数据 | +| BOJ | | 日本银行数据 | +| BOF | The Banque de France is responsible for monetary policy through policies of the European System of Central Banks and providing data on key economic indictors. | 法国银行数据 | +| LPPM | Price data on the market-clearing level for Palladium and Platinum around the world. | 白金和钯价格数据 | +| JOHNMATT | Current and historical data on platinum group metals such as prices, supply, and demand. | 稀有金属价格数据 | +| NAHB | Housing and economic indices for the United States. | 美国住房指数 | +| RATEINF | Inflation Rates and the Consumer Price Index CPI for Argentina, Australia, Canada, Germany, Euro area, France, Italy, Japan, New Zealand and more. | 通货膨胀率 | +| RENCAP | Data on the IPO market in the United States. | IPO数据 | +| ML | Merrill Lynch, a major U.S. bank, publishes data on yield rates for corporate bonds in different regions. | 公司债券收益率数据 | +| MULTPL | No description for this database yet. | S&P 500 | +| RICI | Composite, USD based, total return index, representing the value of a basket of commodities consumed in the global economy. | 商品指数 | +| AAII | American Association of Individual Investor’s sentiment data. | 投资者情绪 | +| WORLDAL | World Aluminium capacity and production in thousand metric tonnes. | 铝价格 | +| WGC | The World Gold Council is a market development organization for the gold industry. It publishes data on gold prices in different currencies. | 黄金价格 | +| MX | Montreal Exchange is a derivatives exchange that trades in futures contracts and options for equities, indices, currencies, ETFs, energy, and interest rates. | 加拿大期货数据 | +| UMICH | The University of Michigan’s consumer survey - data points for the most recent 6 months are unofficial; they are sourced from articles in the Wall Street Journal. | 消费者情绪 | +| BUCHARESTSE | The Bucharest Stock Exchange publishes data on it activity in equity, rights, bonds, fund units, structured products, and futures contracts. | 布加勒斯特证券交易所数据 | +| BSE | End of day prices, indices, and additional information for companies trading on the Bombay Stock Exchange in India. | 孟买证券交易所数据 | +| CFTC | Weekly Commitment of Traders and Concentration Ratios. Reports for futures positions, as well as futures plus options positions. New and legacy formats. | 商品期货交易委员会报告 | +| ACC | Chemical Activity Barometer (CAB) published by the American Chemistry Council (ACC). The CAB is an economic indicator that helps anticipate peaks and troughs in the overall US economy and highlights potential trends in other industries in the US. | 美国化学理事会数据 | +| AMECO | Annual macro-economic database of the European Commission's Directorate General for Economic and Financial Affairs (DG ECFIN). | 欧盟委员会年度宏观经济数据库 | +| MORTGAGEX | Historical housing data on ARM indexes. | 可调利率抵押贷款指数 | +| BUCHARESTSE | The Bucharest Stock Exchange publishes data on it activity in equity, rights, bonds, fund units, structured products, and futures contracts. | 布加勒斯特证券交易所数据 | +| AMECO | Annual macro-economic database of the European Commission's Directorate General for Economic and Financial Affairs (DG ECFIN). | 欧盟委员会年度宏观经济数据库 | +| ACC | Chemical Activity Barometer (CAB) published by the American Chemistry Council (ACC). The CAB is an economic indicator that helps anticipate peaks and troughs in the overall US economy and highlights potential trends in other industries in the US. | 美国化学理事会数据 | +| ABMI | Indicators of Chinese and Japanese bond markets, such as size and composition, market liquidity, yield returns, and volatility. | 亚洲债券市场计划 | +| BITAL | This database provides data on stock future contracts from the Borsa Italiana, now part of London Stock Exchange Group. | | +| BANKRUSSIA | Primary indicators from the Bank of Russia, including data on the banking sector, money supply, financial markets and macroeconomic statistical data. | 俄罗斯银行数据 | +| FMAC | Data from Freddie Mac’s Primary Mortgage Market Survey and other region specific historical mortgage rates. | 房地美数据 | +| BOC | Economic, financial and banking data for Canada. Includes interest rates, inflation, national accounts and more. Daily updates. | 加拿大银行统计数据库 | +| BSE | End of day prices, indices, and additional information for companies trading on the Bombay Stock Exchange in India. | 孟买证券交易所数据 | \ No newline at end of file From 00f8d9353d6a810d2ff430ae8adff2bbf9766d15 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:05 +0800 Subject: [PATCH 080/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md new file mode 100644 index 0000000..12dd894 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.5.0-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `~/.cql` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +./cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 99f29421a30e706eed61709e880b713b99fb8f65 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:06 +0800 Subject: [PATCH 081/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.2.0/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/usecase.md b/website/translated_docs/zh-CN/version-0.2.0/usecase.md new file mode 100644 index 0000000..690cf7e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.2.0-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From da97978a2e1f40c5b6f0147cac3cd08e5cbd9990 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:08 +0800 Subject: [PATCH 082/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/quickstart.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/quickstart.md b/website/translated_docs/zh-CN/version-0.2.0/quickstart.md new file mode 100644 index 0000000..fffaf95 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/quickstart.md @@ -0,0 +1,148 @@ +--- +id: version-0.2.0-quickstart +title: '🌏 TestNet 快速开始' +original_id: quickstart +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.2.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.2.0/CovenantSQL-v0.2.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.2.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.2.0/CovenantSQL-v0.2.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-utils` 等。 + +| 工具名 | 介绍 | +| ---------- | --------------------------------------------------- | +| cql | CovenantSQL 的客户端,类似 mysql 命令,用于执行 SQL | +| cql-utils | CovenantSQL 工具箱,用于和主链交互 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.2.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) ,或者使用以下命令: + +```bash +mkdir conf +wget https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml -O conf/config.yaml +wget https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +./cql -config conf/config.yaml -create 1 +``` + +输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +./cql -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库SDK + +- [Golang开发指引](./development) + +## SQLChain区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入你生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为你的钱包充值。有任何问题请来这里讨论:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 7e1f903d3edd109bfec748192802d8a73791693d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:09 +0800 Subject: [PATCH 083/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/deployment.md | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/deployment.md b/website/translated_docs/zh-CN/version-0.1.0/deployment.md new file mode 100644 index 0000000..524f5aa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/deployment.md @@ -0,0 +1,156 @@ +--- +id: version-0.1.0-deployment +title: '🐳 Docker 一键部署' +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`127.0.0.1:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 \ No newline at end of file From ffa03d441ad4de0ccdd3d91f306041ee16fc7b60 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:10 +0800 Subject: [PATCH 084/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.2.0/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/api.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/api.md b/website/translated_docs/zh-CN/version-0.2.0/api.md new file mode 100644 index 0000000..390b56c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.2.0-api +title: '👩🏻‍💻 CovenantSQL API' +original_id: api +--- +## TBD \ No newline at end of file From 90fa6797ec008376b08e64c09a83fb11ea26f30d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:12 +0800 Subject: [PATCH 085/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.2.0/nav.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/nav.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/nav.md b/website/translated_docs/zh-CN/version-0.2.0/nav.md new file mode 100644 index 0000000..f94a14a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/nav.md @@ -0,0 +1,22 @@ +--- +id: version-0.2.0-nav +title: '📖 使用导航' +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 40b4b0e9cc125fd71edde410ae1ae9fbc6f90866 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:13 +0800 Subject: [PATCH 086/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..78629bb --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md @@ -0,0 +1,96 @@ +--- +id: version-0.5.0-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `~/.cql` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ~/.cql/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额(未加-config参数时,命令会自动找~/.cql目录的config.yaml文件): + +```bash +$ cql -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From a6030e68e301e7dafb6197be25b6c74ae10ecca1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:16 +0800 Subject: [PATCH 087/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.5.0/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md new file mode 100644 index 0000000..ad9178a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.5.0-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +* `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +* `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +### SQLChain Observer + +我们在`:11108`端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 6213cff8dd717282574d8ad33115e863ba98cc3b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:17 +0800 Subject: [PATCH 088/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..ebd52dd --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.5.0-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 3daa5f82dbf2d79ad04c7a54cc6da2e4aeba9008 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:18 +0800 Subject: [PATCH 089/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..956b8e5 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.5.0-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 9196b233cc8ddf9c31760fd44aa8582e0c9ab413 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:20 +0800 Subject: [PATCH 090/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..a89f54d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.5.0-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From 0930f8e56c9c24c55d4f1d499bd41200cb1aeb15 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:21 +0800 Subject: [PATCH 091/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/cql.md | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/cql.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/cql.md b/website/translated_docs/zh-CN/version-0.1.0/cql.md new file mode 100644 index 0000000..49710cc --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/cql.md @@ -0,0 +1,144 @@ +--- +id: version-0.1.0-cql +title: '🖥️ CQL 命令行工具' +original_id: cql +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络。 + +## 查询余额 + +查询余额有两个命令:`cql -get-balance` 和 `cql -token-balance `。其中 `-get-balance` 将返回用户账户中 `Particle` 与 `Wave` 的数量,`-token-balance ` 将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +./cql -config conf/config.yaml -token-balance Particle +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +./cql -config conf/config.yaml -token-balance Bitcoin +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql -transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `-get-balance` 或者 `-token-balance ` 确定。 + +## 数据库权限管理 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin`, `Write` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql -update-perm` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 \ No newline at end of file From de73b0e04e254e3c07ac1cf4b80aac6be853996e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:22 +0800 Subject: [PATCH 092/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..d2fe9ab --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.4.0-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From f7817ec213d5895a2db269d1f63b05e281602b18 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:24 +0800 Subject: [PATCH 093/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.1.0/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/usecase.md b/website/translated_docs/zh-CN/version-0.1.0/usecase.md new file mode 100644 index 0000000..f455dcb --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.1.0-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From 6566cb29bac59b985010350cdc7781d85d855d04 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:25 +0800 Subject: [PATCH 094/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../getting-started-overview-zh.md | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.0.6/getting-started-overview-zh.md new file mode 100644 index 0000000..c170277 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/getting-started-overview-zh.md @@ -0,0 +1,122 @@ +--- +id: version-0.0.6-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +## 文章 + +团队成员发表过的论文 + +- [迅雷水晶:一种新颖的基于众筹的内容分发平台](https://dl.acm.org/citation.cfm?id=2736085) +- [基于众筹的视频服务系统性能分析](https://ieeexplore.ieee.org/abstract/document/7114727/) +- [迅雷水晶性能分析:基于众筹的视频分发平台](https://ieeexplore.ieee.org/abstract/document/7762143/) + +这些启发了我们: + +- [比特币:P2P电子现金系统](https://bitcoin.org/bitcoin.pdf) +- [S/Kademlia](https://github.com/thunderdb/research/wiki/Secure-Kademlia) + - [S/Kademlia: 一种针对密钥的实用方法](https://ieeexplore.ieee.org/document/4447808/) +- [vSQL: 验证动态外包数据库上的任意SQL查询](https://ieeexplore.ieee.org/abstract/document/7958614/) + +## Libs + +### 网络栈 + +[DH-RPC](rpc/) := TLS - Cert + DHT + +| 层 | 应用 | +|:------ |:------------------------------------------------------------------------------------------------------------:| +| 远程调用协议 | `net/rpc` | +| 寻址 | [**C**onsistent **S**ecure **DHT**](https://godoc.org/github.com/CovenantSQL/CovenantSQL/consistent) | +| 会话池 | Session Pool | +| 多路复用 | [smux](https://github.com/xtaci/smux) | +| 传输安全 | [**E**nhanced **TLS**](https://github.com/CovenantSQL/research/wiki/ETLS(Enhanced-Transport-Layer-Security)) | +| 网络 | TCP or KCP for optional later | + +#### 测试工具 + +- [全球网络拓扑模拟器(GNTE)](https://github.com/CovenantSQL/GNTE) 用于网络模拟 +- [线性一致性测试](https://github.com/anishathalye/porcupine) + +#### 接口 + +CovenantSQL仍在建设中,测试网已经发布,[尝试一下](https://testnet.covenantsql.io/). + +- [Golang](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) +- [Java](https://github.com/CovenantSQL/covenant-connector/) +- [NodeJS](https://github.com/CovenantSQL/node-covenantsql/) +- [Python](https://github.com/CovenantSQL/python-driver/) +- Coding for more…… + +关注我们或[![follow on Twitter](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40CovenantLabs)](https://twitter.com/intent/follow?screen_name=CovenantLabs) 保持更新 + +## 测试网 + +- [快捷入口](https://testnet.covenantsql.io/quickstart) +- [测试网水龙头](https://testnet.covenantsql.io/) + +## 联系我们 + +- [邮箱地址](mailto:webmaster@covenantsql.io) +- [ ![follow on Twitter](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40CovenantLabs)](https://twitter.com/intent/follow?screen_name=CovenantLabs) + +- [![Join the chat at https://gitter.im/CovenantSQL/CovenantSQL](https://badges.gitter.im/CovenantSQL/CovenantSQL.svg)](https://gitter.im/CovenantSQL/CovenantSQL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) \ No newline at end of file From 1a50aa56caa736dc2eecc9ad66f4a54f4c0f207d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:26 +0800 Subject: [PATCH 095/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-zh.md new file mode 100644 index 0000000..3bde205 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.0.6-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From 396995abadf8ae7c55fba1fc3ac52d01e4cffd53 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:28 +0800 Subject: [PATCH 096/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/development-golang-client-zh.md new file mode 100644 index 0000000..0089def --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.0.6-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `conf` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +$ cql-utils -tool confgen -root conf +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 4771f3dafa0cf885827c07a5bbf89f6501a5f4f7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:30 +0800 Subject: [PATCH 097/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/bck/api-json-rpc.md | 440 ++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.0.6/bck/api-json-rpc.md new file mode 100644 index 0000000..7ec30aa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/api-json-rpc.md @@ -0,0 +1,440 @@ +--- +id: version-0.0.6-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_databases": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------- | ---------------------- | ------ | +| 0 | from | integer | start height, included | 1 | +| 1 | to | integer | end height, excluded | 11 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1, 11] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: block object } + ] +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1, true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO", true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | --------- | ------- | ------------------------------------------- | ---------- | +| 0 | since | string | hash as the start point of traverse | "TODO" | +| 1 | direction | string | traverse direction, "backward" or "forward" | "backward" | +| 2 | size | integer | page size, [5, 100] | 20 | + + QhcAe42Xf8cwGUf5NYGQDQ + XNZ9yipFBUV5ySBtreW1MA ↑ forward (in newer blocks) + 9fXd3s5HE5fC8lOYY6uAZA + KhytGjS0xjw5CJvcJYpsNg ← since (paging mark) + 2KOxrKMS4iVDKXnm6HuYiA + 71VwqOMOvAsBXJRMeBruWg ↓ backward (in older blocks) + 0P3k04RKHw8SEMKHxADC8A + + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", "forward", 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionListInBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | --------------------- | ------ | +| 0 | height | integer | block height | 1024 | +| 1 | from | integer | start index, included | 0 | +| 2 | to | integer | end index, excluded | 10 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListInBlock", + "params": [1024, 0, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO", true] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| ----------- | ------- | -------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | string | Create time of the block | +| signee | string | Public key of the node who signed this block | +| signature | string | Signature for the this block | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "signee": "TODO", + "signature": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| ------------ | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| signee | string | Public key of the account who signed this transaction | +| address | string | Account address who signed this transaction | +| signature | string | Signature of this transaction | +| timestamp | string | Create time of the transaction | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "type": 1, + "signee": "TODO", + "address": "TODO", + "signature": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From 5e130bc6d95f567179203084a06854cf10372a10 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:31 +0800 Subject: [PATCH 098/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/guide-zh.md new file mode 100644 index 0000000..6c441ac --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.0.6-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 552ca931d1ce579bc9eb1b5eea6df29dcfdc86c1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:33 +0800 Subject: [PATCH 099/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../getting-started-testnet-zh.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.0.6/getting-started-testnet-zh.md new file mode 100644 index 0000000..c3a90f9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/getting-started-testnet-zh.md @@ -0,0 +1,93 @@ +--- +id: version-0.0.6-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +运行完成后,`cql-utils`会在 `./conf` 目录生成一个配置文件。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `./conf` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ./conf/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -config conf/config.yaml -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From cc903946475237af75d1b74866bf522944916d5c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:34 +0800 Subject: [PATCH 100/421] New translations development.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/development.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/development.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/development.md b/website/translated_docs/zh-CN/version-0.0.6/development.md new file mode 100644 index 0000000..4c162b3 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/development.md @@ -0,0 +1,173 @@ +--- +id: version-0.0.6-development +title: 使用 CovenantSQL 开发 App +original_id: development +--- +## Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 72782824444af2685cbcc76ccdf0b39f031f233a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:35 +0800 Subject: [PATCH 101/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.0.6/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/qna.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/qna.md b/website/translated_docs/zh-CN/version-0.0.6/qna.md new file mode 100644 index 0000000..519f07d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.0.6-qna +title: 常见问题解答 +original_id: qna +--- +## TBD \ No newline at end of file From 2303cf18b137ba3b17d0e2a055e8dfb5e72dfb7e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:37 +0800 Subject: [PATCH 102/421] New translations getting-started-zh.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.0.6/getting-started-zh.md new file mode 100644 index 0000000..a7c7ce9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.0.6-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +* `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +* `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 02b213b08aec248a5c580c788df5841108631126 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:39 +0800 Subject: [PATCH 103/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..1bbea8e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.0.6-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 3db95772501b59726e5614ce181a321f64118aab Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:40 +0800 Subject: [PATCH 104/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/deployment.md | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/deployment.md b/website/translated_docs/zh-CN/version-0.0.6/deployment.md new file mode 100644 index 0000000..ff3376a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/deployment.md @@ -0,0 +1,126 @@ +--- +id: version-0.0.6-deployment +title: 部署 CovenantSQL 私有链 +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 \ No newline at end of file From 656d37d1778813d31dd1f34199f17ef1031dd490 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:41 +0800 Subject: [PATCH 105/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..1bbea8e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.0.6-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From c2b935a825fc865743f2b210e1e5caf44d8499c8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:43 +0800 Subject: [PATCH 106/421] New translations getting-started.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/getting-started.md | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/getting-started.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/getting-started.md b/website/translated_docs/zh-CN/version-0.0.6/getting-started.md new file mode 100644 index 0000000..ff3aeb8 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/getting-started.md @@ -0,0 +1,229 @@ +--- +id: version-0.0.6-getting-started +title: CovenantSQL 一键开箱使用 +original_id: getting-started +--- +## 一键部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 部署 CovenantSQL + +执行以下的命令在本地运行 CovenantSQL + +```shell +$ git clone https://github.com/CovenantSQL/CovenantSQL +$ cd CovenantSQL +$ make start +``` + +后续的所有命令,wd 都是在 clone 的 CovenantSQL 源码目录中 + +### 检查运行状态 + +```shell +$ docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +## 使用 CovenantSQL + +### 创建数据库 + +创建一个单节点的数据库实例,可以将 create 的参数调整为 2 或者最多至 3(当前一键部署只部署了 3 个miner 节点,只能支持最多 3 节点的实例) + +```shell +$ docker cp covenantsql_bp_1:/app/cql ./ +$ ./cql -config ./test/service/node_c/config.yaml -create 1 +``` + +将会得到数据库的 dsn 串,当前示例是 `covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4` + +```shell +INFO[0001] the newly created database is: "covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4" +``` + +### 使用 cql 命令行访问数据库 + +```shell +$ ./cql -config ./test/service/node_c/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +执行任何常见 SQL 命令(兼容 SQLite 语法 和 部分类似 MySQL 的 SHOW 语法) + +```shell +INFO[0000] connecting to "covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4" +Connected with driver covenantsql (feature/kayakPerformance-a6e183ed-20181107003651) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +示例 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> create table test (test string); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> show tables; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> \q + +$ +``` + +## 使用 Java/Python Driver 操作 CovenantSQL + +当前 Java/Python Driver 需要依赖 ```covenantsql_adapter``` 服务使用,使用前确保 `covenantsql_adapter` 服务运行正常 + +### Java JDBC Driver 使用 + +**需要使用 maven 编译 java-connector + +```shell +$ git clone https://github.com/CovenantSQL/covenant-connector +$ cd covenant-connector/covenantsql-java-connector +$ mvn package -Dmaven.test.skip=true +``` + +编译后将会得到 3 个编译 jar 结果 + +```shell +$ ls -l target/*.jar +target/covenantsql-java-connector-1.0-SNAPSHOT-jar-with-dependencies.jar +target/covenantsql-java-connector-1.0-SNAPSHOT-shaded.jar +target/covenantsql-java-connector-1.0-SNAPSHOT.jar +``` + +Driver 提供了一个简单的 Example 测试 + +Example 源码在 `./src/main/java/io/covenantsql/connector/example/Example.java` + +使用 dsn 串中的 host 部分 ```0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4``` 设置为 `COVENANTSQL_DATABASE` 这个 property 来测试 example + +```shell +$ java -DCOVENANTSQL_DATABASE=0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 -cp target/covenantsql-java-connector-1.0-SNAPSHOT-jar-with-dependencies.jar io.covenantsql.connector.example.Example +``` + +可以看到插入和查询的结果 + +```shell +[main] INFO io.covenantsql.connector.CovenantDriver - covenantsql driver registered +Build url: jdbc:covenantsql://127.0.0.1:11105/0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +Connecting to database... +Creating statement... +ID: 1, Email: Apple, Password: appleisdelicious, Time: 00:01:17 +``` + +### Python Driver 使用 + +**当前支持 `python3` 下使用 Python Driver,`python2` 将会在兼容性测试后提供 + +Demo 依赖 `python3` 和 `pipenv` + +Python3: https://www.python.org/download/releases/3.0/ + +Pipenv: https://github.com/pypa/pipenv + +安装依赖完成后,clone demo 并安装依赖到 pipenv + +```shell +$ git clone https://github.com/CovenantSQL/python-demos.git +$ cd python-demos +$ pipenv install +``` + +使用 dsn 串中的 host 部分 `0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4`设置为 `COVENANTSQL_DATABASE` env 变量来执行测试 + +`COVENANTSQL_ROOT` 环境变量为开始 clone 的 CovenantSQL 代码目录 + +```shell +$ pipenv shell +(python-demos-d0igWVYT) $ cd hello-covenantsql +(python-demos-d0igWVYT) $ chmod u+x main.py +(python-demos-d0igWVYT) $ COVENANTSQL_DATABASE=0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 \ +COVENANTSQL_PRIVATE_KEY=${COVENANTSQL_ROOT}/test/service/node_c/admin.test.covenantsql.io-key.pem \ +COVENANTSQL_PROXY_PEM=${COVENANTSQL_ROOT}/test/service/node_c/admin.test.covenantsql.io.pem ./main.py +``` + +执行结果如下(因为使用了 Java JDBC Driver插入了一行数据,这里可以看到两行数据) + +```shell +create table +insert sample data +affected rows: 1, lastrowid: 2 +select data from the table +(1, '2018-11-07T16:01:17Z', 'Apple', 'appleisdelicious') +(2, '2018-11-07T16:10:29Z', 'Apple', 'appleisdelicious') +``` + +退出 pipenv + +```shell +(python-demos-d0igWVYT) $ deactive +$ +``` + +## 使用 MySQL Client(version <=5.7)操作 CovenantSQL + +**当前只支持 version <=5.7 的 MySQL Client 访问,且依赖 `covenantsql_mysql_adapter` 服务使用,使用前确保 `covenantsql_mysql_adapter` 服务运行正常 + +```shell +$ mysql -h127.0.0.1 -P11107 -uroot -pcalvin -D0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +可以执行任何常见 SQL 命令进行测试 + +```shell +Reading table information for completion of table and column names +You can turn off this feature to get a quicker startup with -A + +Welcome to the MySQL monitor. Commands end with ; or \g. +Your MySQL connection id is 10001 +Server version: 5.7.0 + +Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + +Oracle is a registered trademark of Oracle Corporation and/or its +affiliates. Other names may be trademarks of their respective +owners. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +mysql> show tables; ++-----------------+ +| name | ++-----------------+ +| test | +| users | +| sqlite_sequence | ++-----------------+ +3 rows in set (0.02 sec) + +mysql> +``` \ No newline at end of file From 0a65b9a8c668a897d80504266457dca83466d742 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:44 +0800 Subject: [PATCH 107/421] New translations install.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/install.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/install.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/install.md b/website/translated_docs/zh-CN/version-0.0.6/install.md new file mode 100644 index 0000000..c81fb23 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/install.md @@ -0,0 +1,115 @@ +--- +id: version-0.0.6-install +title: 安装 CovenantSQL 客户端 +original_id: install +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [NodeJS](https://github.com/CovenantSQL/node-covenantsql) +- [Web (WIP)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From b2364b5cd32703191e99be1e86d4c3f3243e6b7b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:45 +0800 Subject: [PATCH 108/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.0.6/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/usecase.md b/website/translated_docs/zh-CN/version-0.0.6/usecase.md new file mode 100644 index 0000000..87f5b00 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.0.6-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From d876276389451d3ac8d24914dbd7ec3c337c10da Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:47 +0800 Subject: [PATCH 109/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../version-0.0.6/development-cmd-cql-zh.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-zh.md new file mode 100644 index 0000000..3bde205 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/development-cmd-cql-zh.md @@ -0,0 +1,77 @@ +--- +id: version-0.0.6-cql +title: 使用命令行客户端 cql 创建数据库 +original_id: cql +--- +本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 生成默认配置文件 + +首先需要一个 config 文件和由你输入的主密码(master key)来初始化,其中主密码用来加密解密本地密钥对。使用 `cql-utils` 工具进行配置文件生成后,你可以在生成的配置文件目录下找到密钥文件。 + +具体请参考: [cql-utils 使用文档](https://github.com/CovenantSQL/docs/tree/master/development-cmd-utils-zh.md#使用) 中配置文件及钱包地址生成相关章节。 + +## 检查钱包余额 + +使用 `cql` 命令来检查钱包余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] +### Public Key ### +0388954cf083bb6bb2b9c7248849b57c76326296fcc0d69764fc61eedb5b8d820c +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +这里我们得到结果 **"stable coin balance is: 100"**。 + +## 初始化一个 CovenantSQL 数据库 + +准备好配置文件和主密码后就可以使用 `cql` 命令来创建数据库了,你的数据库 ID 将会输出到屏幕上: + +```bash +# if a non-default password applied on master key, use `-password` to pass it +$ cql -config conf/config.yaml -create 1 +INFO[0000] +### Public Key ### +039bc931161383c994ab9b81e95ddc1494b0efeb1cb735bb91e1043a1d6b98ebfd +### Public Key ### + caller="privatekeystore.go:116 crypto/kms.InitLocalKeyPair" +INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213 caller="main.go:297 main.main" +``` + +这里 `-create 1` 表示创建一个单节点的 SQLChain。 + +```bash +$ cql -config conf/config.yaml -dsn covenantsql://address +``` + +`address` 就是你的数据库 ID。 + +`cql` 命令的详细使用帮助如下: + +```bash +$ cql -help +``` + +## 使用 `cql` + +现在可以使用 `cql` 进行数据库操作了: + +```bash +co:address=> show tables; +``` \ No newline at end of file From 09aacfc7a09dbc0e0738dede847c6f5343c45587 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:48 +0800 Subject: [PATCH 110/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/quickstart.md | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/quickstart.md b/website/translated_docs/zh-CN/version-0.0.6/quickstart.md new file mode 100644 index 0000000..2ea23d0 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/quickstart.md @@ -0,0 +1,107 @@ +--- +id: version-0.0.6-quickstart +title: 快速开始 +original_id: quickstart +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。你将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为你准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示你创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [NodeJS](https://github.com/CovenantSQL/node-covenantsql) +- [Web (WIP)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看你的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入你的数据库地址。 + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +你可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入你生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为你的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 16446131040df67e2b1041858d7b037b2dd8ee6b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:49 +0800 Subject: [PATCH 111/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/intro.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/intro.md b/website/translated_docs/zh-CN/version-0.0.6/intro.md new file mode 100644 index 0000000..f71ecd6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.0.6-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 6a4c2cb8fb9cb4405ed7e3fdb5e678e1a30192b4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:51 +0800 Subject: [PATCH 112/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.0.6/development-golang-client-zh.md new file mode 100644 index 0000000..0089def --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.0.6-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `conf` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +$ cql-utils -tool confgen -root conf +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 0425df815d701f4651f10358a183d0b72e16177e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:53 +0800 Subject: [PATCH 113/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.0.6/api-json-rpc.md | 440 ++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.0.6/api-json-rpc.md new file mode 100644 index 0000000..7ec30aa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/api-json-rpc.md @@ -0,0 +1,440 @@ +--- +id: version-0.0.6-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_databases": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------- | ---------------------- | ------ | +| 0 | from | integer | start height, included | 1 | +| 1 | to | integer | end height, excluded | 11 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1, 11] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: block object } + ] +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1, true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO", true] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | --------- | ------- | ------------------------------------------- | ---------- | +| 0 | since | string | hash as the start point of traverse | "TODO" | +| 1 | direction | string | traverse direction, "backward" or "forward" | "backward" | +| 2 | size | integer | page size, [5, 100] | 20 | + + QhcAe42Xf8cwGUf5NYGQDQ + XNZ9yipFBUV5ySBtreW1MA ↑ forward (in newer blocks) + 9fXd3s5HE5fC8lOYY6uAZA + KhytGjS0xjw5CJvcJYpsNg ← since (paging mark) + 2KOxrKMS4iVDKXnm6HuYiA + 71VwqOMOvAsBXJRMeBruWg ↓ backward (in older blocks) + 0P3k04RKHw8SEMKHxADC8A + + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", "forward", 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionListInBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | --------------------- | ------ | +| 0 | height | integer | block height | 1024 | +| 1 | from | integer | start index, included | 0 | +| 2 | to | integer | end index, excluded | 10 | + +**Constraints:** `to - from ∈ [5, 100]` + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListInBlock", + "params": [1024, 0, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + { TODO: transaction object } + ] +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO", true] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| ----------- | ------- | -------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | string | Create time of the block | +| signee | string | Public key of the node who signed this block | +| signature | string | Signature for the this block | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "signee": "TODO", + "signature": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| ------------ | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| signee | string | Public key of the account who signed this transaction | +| address | string | Account address who signed this transaction | +| signature | string | Signature of this transaction | +| timestamp | string | Create time of the transaction | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "type": 1, + "signee": "TODO", + "address": "TODO", + "signature": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From 02196b260eeea702050f87e20f3977c425df3f86 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:54 +0800 Subject: [PATCH 114/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.0.6/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/api.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/api.md b/website/translated_docs/zh-CN/version-0.0.6/api.md new file mode 100644 index 0000000..5e4a668 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.0.6-api +title: CovenantSQL API +original_id: api +--- +## TBD \ No newline at end of file From 80702bc902d5311da0c57e6ee4cad7f1a2ee8bed Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:55 +0800 Subject: [PATCH 115/421] New translations nav.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.0.6/nav.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/nav.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/nav.md b/website/translated_docs/zh-CN/version-0.0.6/nav.md new file mode 100644 index 0000000..b2842cb --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/nav.md @@ -0,0 +1,18 @@ +--- +id: version-0.0.6-nav +title: 使用导航 +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🔗 Docker 一键部署 CovenantSQL 测试网](./deployment) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 6811ef49f277b22a5fcba31f0a85a7172f73569d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:56 +0800 Subject: [PATCH 116/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..174cc0d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.0.6-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From d4a58d68ba14d07b5753ba71598b791cb2b86c9e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:57 +0800 Subject: [PATCH 117/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.0.6/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-zh.md new file mode 100644 index 0000000..a7c7ce9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.0.6-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +* `conf/private.key`: 为您生成的私钥通过主密码加密保存在该文件中,您的账号地址需要使用该文件创建; +* `conf/config.yaml`: 为您生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp +covenantsql_explorer /bin/sh -c MAGIC_DOLLAR='$ ... Up 0.0.0.0:11108->80/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11106->4663/tcp +``` + +### SQLChain Explorer + +我们在`:11108`端口提供了一个 SQLChain 的 Explorer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From a1642a5ee717b7d67299c7067f2b0df69421aa80 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:25:59 +0800 Subject: [PATCH 118/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/quickstart.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/quickstart.md b/website/translated_docs/zh-CN/version-0.1.0/quickstart.md new file mode 100644 index 0000000..8892816 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/quickstart.md @@ -0,0 +1,148 @@ +--- +id: version-0.1.0-quickstart +title: '🌏 TestNet 快速开始' +original_id: quickstart +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.1.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.1.0/CovenantSQL-v0.1.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.1.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.1.0/CovenantSQL-v0.1.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-utils` 等。 + +| 工具名 | 介绍 | +| ---------- | --------------------------------------------------- | +| cql | CovenantSQL 的客户端,类似 mysql 命令,用于执行 SQL | +| cql-utils | CovenantSQL 工具箱,用于和主链交互 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.1.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) ,或者使用以下命令: + +```bash +mkdir conf +wget https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml -O conf/config.yaml +wget https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +./cql -config conf/config.yaml -create 1 +``` + +输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +./cql -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库SDK + +- [Golang开发指引](./development) + +## SQLChain区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: conf/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你创建一个 `conf` 目录: + +- `conf/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `conf/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private conf/private.key +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入你生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为你的钱包充值。有任何问题请来这里讨论:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +使用 cql 命令行工具查询余额: + +```shell +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From ffdf48ae45f87b30a5fbf3eaafe5b0e44f4010a6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:00 +0800 Subject: [PATCH 119/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/bck/guide-zh.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/guide-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/guide-zh.md new file mode 100644 index 0000000..5b25df1 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/guide-zh.md @@ -0,0 +1,114 @@ +--- +id: version-0.4.0-guide-zh +title: 快速开始 +original_id: guide-zh +--- +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +- [Go](./development-golang-client-zh.md) +- [Java](https://github.com/CovenantSQL/covenant-connector) +- [Python](https://github.com/CovenantSQL/python-driver) +- [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +- [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 8621957d69bfc58b5669cfc9ad66d084da9ac01d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:01 +0800 Subject: [PATCH 120/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/intro.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/intro.md b/website/translated_docs/zh-CN/version-0.1.0/intro.md new file mode 100644 index 0000000..02dc58b --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.1.0-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 7225d158bfa89b4bc6d41377d03535a03a0bf69d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:02 +0800 Subject: [PATCH 121/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.1.0/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/api.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/api.md b/website/translated_docs/zh-CN/version-0.1.0/api.md new file mode 100644 index 0000000..a67acb9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.1.0-api +title: '👩🏻‍💻 CovenantSQL API' +original_id: api +--- +## TBD \ No newline at end of file From 844d4d25e1567a96447dbd14d6f15e06d6a673e2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:04 +0800 Subject: [PATCH 122/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.1.0/nav.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.1.0/nav.md diff --git a/website/translated_docs/zh-CN/version-0.1.0/nav.md b/website/translated_docs/zh-CN/version-0.1.0/nav.md new file mode 100644 index 0000000..f3161b6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.1.0/nav.md @@ -0,0 +1,22 @@ +--- +id: version-0.1.0-nav +title: '📖 使用导航' +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From f8bcd0c13cd8fdec3fdf49d19457f7e8b6445600 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:05 +0800 Subject: [PATCH 123/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..e4c0d49 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-testnet-zh.md @@ -0,0 +1,96 @@ +--- +id: version-0.4.0-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `~/.cql` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ~/.cql/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额(未加-config参数时,命令会自动找~/.cql目录的config.yaml文件): + +```bash +$ cql -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From a255e50c61f78a992955794849aa2b94e3aca30f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:07 +0800 Subject: [PATCH 124/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.4.0/bck/getting-started-zh.md | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-zh.md new file mode 100644 index 0000000..0a86826 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-zh.md @@ -0,0 +1,486 @@ +--- +id: version-0.4.0-local-deployment +title: CovenantSQL 综述 +original_id: local-deployment +--- +# CovenantSQL 介绍 + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可变成 ĐApp +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是用户的钱包,那么 CovenantSQL 就是是用户的去中心化数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密 保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 + +# 安装 CovenantSQL 客户端 + +## 下载 CovenantSQL 工具包 + +请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 + +## 创建并访问 CovenantSQL 数据库 + +我们已经上线了 CovenantSQL 测试网,也为您准备了一个公共的测试账号,请下载账号配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/feature/chainBus-SQLChain/test/service/node_c/config.yaml)、[private.key](https://github.com/CovenantSQL/CovenantSQL/raw/feature/chainBus-SQLChain/test/service/node_c/private.key) 用于测试。 + +**注**:该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放您的应用信息,我们会不定期清理数据库数据。 + +### 使用 cql 命令行工具创建数据库 + +```shell +./cql -config config.yaml -create 1 +``` + +输出: + + INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" + + +这里表示您创建了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库。 + +### 使用 cql 命令行工具访问数据库 + +```shell +./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,您可以按您操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 使用数据库驱动访问数据库 + +* [Go](./development-golang-client-zh.md) +* [Java](https://github.com/CovenantSQL/covenant-connector) +* [Python](https://github.com/CovenantSQL/python-driver) +* [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) + +## 通过区块浏览器查看您的数据库操作记录 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,您可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。查询时,请在其页面右上角填入您的数据库地址。 + +## 创建账号 + +我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +* `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +* `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + + wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 + + +您可以在我们的 [CovenantSQL 测试网](https://testnet.covenantsql.io/) 输入您生成的钱包地址,通过发微博、推特等社交媒体来帮助我们推广我们的项目,我们会为您的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +## 部署私有 CovenantSQL 数据库(搭建私链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +* [Docker 一键部署 CovenantSQL 测试网](./getting-started-zh.md) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 + +# 部署 CovenantSQL + +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 启动 Docker 容器 + +执行以下的命令在本地运行 CovenantSQL + +```shell +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +make docker +make start +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行`export COVENANTSQL_ROOT=$PWD`存为环境变量 + +### 检查运行状态 + +```shell +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +### SQLChain Observer + +我们在`:11108`端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况 + +# 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +cql -config config/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +cql -config config/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +# 使用 CovenantSQL 开发 App + +## Golang 使用 CovenantSQL + +#### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +#### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +#### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +#### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +#### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` + +# CovenantSQL API + +# 常见问题解答 + +补充 \ No newline at end of file From 95ad41bd6b7c48737783ffcb09acef22109dc8a4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:08 +0800 Subject: [PATCH 125/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../bck/development-cmd-cql-utils-zh.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-utils-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-utils-zh.md new file mode 100644 index 0000000..88329cb --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/development-cmd-cql-utils-zh.md @@ -0,0 +1,41 @@ +--- +id: version-0.4.0-keygen +title: 使用 cql-utils 生成密钥与钱包 +original_id: keygen +--- +`cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 + +## 安装 + +下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译: + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中* + +## 使用 + +### 生成公私钥对 + + $ cql-utils -tool keygen + Enter master key(press Enter for default: ""): + ⏎ + Private key file: private.key + Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0 + + +生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。 + +### 使用私钥文件或公钥生成钱包地址 + + $ cql-utils -tool addrgen -private private.key + Enter master key(default: ""): + ⏎ + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + $ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8 + wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 + + +你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。 \ No newline at end of file From 8bf372418839c485f03db9c7329b7fd2f3e99bcf Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:09 +0800 Subject: [PATCH 126/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../bck/getting-started-overview-zh.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-overview-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-overview-zh.md new file mode 100644 index 0000000..5573dce --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/getting-started-overview-zh.md @@ -0,0 +1,63 @@ +--- +id: version-0.4.0-intro +title: 简介 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +- **SQL**: 支持 SQL-92 标准 +- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +- **隐私**: 通过加密和授权许可进行访问 +- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +#### 一行代码接入区块链数据 + +```go +sql.Open("CovenantSQL", dbURI) +``` + +# # + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +- 第一层: **全局共识层**(主链,架构图中的中间环): + - 整个网络中只有一个主链。 + - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +- 第二层: **SQL 共识层**(子链,架构图中的两边环): + - 每个数据库都有自己独立的子链。 + - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎): + - 每个数据库都有自己独立的分布式引擎。 + - 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 076fa80497c1b0b67832b30cf7eec73b95a03489 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:11 +0800 Subject: [PATCH 127/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../bck/development-golang-client-zh.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/development-golang-client-zh.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.4.0/bck/development-golang-client-zh.md new file mode 100644 index 0000000..68d800f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/development-golang-client-zh.md @@ -0,0 +1,108 @@ +--- +id: version-0.4.0-golang-client +title: 使用 Golang 驱动访问数据库 +original_id: golang-client +--- +本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 + +## 开始之前 + +确保 `$GOPATH/bin` 目录在环境变量 `$PATH` 中,执行以下命令 + +```bash +$ go get github.com/CovenantSQL/CovenantSQL/client +$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils +``` + +然后在你的 go 代码中 import 第一个 `client` 包。 + +## 初始化一个 CovenantSQL 客户端 + +首先需要一个 config 文件和 master key 来初始化。master key 用来加密解密本地密钥对。以下是如何用一个自定义 master key 来生成默认的 config 文件: + +### 生成默认的配置文件 + +运行以下 `cql-utils` 命令,输入 master key(类似密码)来生成本地密钥对。等待几十秒,会在 `~/.cql` 文件夹中,生成一个私钥文件和一个名为 `config.yaml` 的配置文件。 + +```bash +./cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: ~/.cql/private.key +Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75 +Generated key pair. +Generating nonce... +INFO[0005] cpu: 1 +INFO[0005] position: 0, shift: 0x0, i: 0 +nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514} +node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514 +Generated nonce. +Generating config file... +Generated nonce. +``` + +有了配置文件之后,可以通过以下 go 代码来初始化 CovenantSQL 客户端: + +```go +client.Init(configFile, masterKey) +``` + +## 客户端使用方式 + +### 创建一个 SQLChain 数据库 + +创建 SQLChain 数据库需要指明需要几个节点(nodeCount变量): + +```go +var ( + dsn string + meta client.ResourceMeta +) +meta.Node = uint16(nodeCount) +dsn, err = client.Create(meta) +// process err +``` + +创建完毕会返回一个 dsn 字符串,用来访问这个数据库。 + +### 查询和执行 + +拿到 dsn 字符串后,可以通过以下代码在 SQLChain 中执行 SQL 语句: + +```go +
db, err := sql.Open("covenantsql", dsn) + // process err + + _, err = db.Exec("CREATE TABLE testSimple ( column int );") + // process err + + _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42) + // process err + + row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;") + + var result int + err = row.Scan(&result) + // process err + fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result) + + err = db.Close() + // process err + +``` + +用法和其他 go sql driver 一致。 + +### 删除数据库 + +使用 dsn 来删除数据库: + +```go + err = client.Drop(dsn) + // process err +``` + +### 完整示例 + +在以下目录中有一个简单示例和复杂示例可以参考 [示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) \ No newline at end of file From 6bbbeab8891eda7a23d3d7ab423b8fcee081f830 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:13 +0800 Subject: [PATCH 128/421] New translations api-json-rpc.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/bck/api-json-rpc.md | 442 ++++++++++++++++++ 1 file changed, 442 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/bck/api-json-rpc.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.4.0/bck/api-json-rpc.md new file mode 100644 index 0000000..3491c49 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/bck/api-json-rpc.md @@ -0,0 +1,442 @@ +--- +id: version-0.4.0-api-json-rpc +title: JSON RPC +original_id: api-json-rpc +--- +> JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. + +CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. + +## Javascript API + +[cql.js](https://github.com/covenantsql/cql.js) is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the [Javascript API](cql-js.md) for more. + +## JSON RPC Endpoint + +| Network | Provider | URL | +| ------------------------ | ------------- | -------------------------------------- | +| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io | +| CovenantSQL Main Network | Covenant Labs | Comming soon :) | + +## JSON RPC API Reference + +### bp_getProtocolVersion + +Returns the current CovenantSQL protocol version. + +#### Parameters + +None. + +#### Returns + +- string - the current CovenantSQL protocol version + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "method": "bp_getProtocolVersion", + "params": [], + "id": 1 +} +``` + +Response: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0.1.0" +} +``` + +### bp_getRunningStatus + +Returns some basic indicators describing the running status of the CovenantSQL network. + +#### Parameters + +None. + +#### Returns + +- object: an object describes the running status of the network. + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getRunningStatus", + "params": [] +} +``` + +Response: + +```js +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "block_height": 182414, // height of the latest block + "count_accounts": 103, // count of the accounts ever created + "count_shardchains": 912414, // count of the databases ever created + "qps": 10241 // estimated QPS of database operations of the whole net + "storage_size": 109870095269 // storage size + } +} +``` + +### bp_getBlockList + +Returns a list of the blocks. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | ---------------------- | ------ | +| 0 | since | integer | since height, excluded | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the blocks, the object in the list is a [Block](#s-block), but **without** transaction details + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockList", + "params": [1024, 1, 10] +} +``` + +Response: [Block](#s-block) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "blocks" [ { TODO: block object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 102, + "pages": 11 + } +} +``` + +### bp_getBlockListByTimeRange + +TODO: as a new API in the next release + +### bp_getBlockByHeight + +Returns information about the block specified by its height. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | height of the block | 1024 | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHeight", + "params": [1] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getBlockByHash + +Returns information about the block specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------- | ------ | +| 0 | hash | string | hash of the block | "TODO" | + +#### Returns + +- object: block information object, it's a [Block](#s-block) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getBlockByHash", + "params": ["TODO"] +} +``` + +Response: [Block](#s-block) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: block object + } +} +``` + +### bp_getTransactionList + +Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ----- | ------- | -------------------- | ------ | +| 0 | since | string | since hash, excluded | "TODO" | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionList", + "params": ["KhytGjS0xjw5CJvcJYpsNg", 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionListOfBlock + +Returns a list of the transactions from a block by the specified height. + +| Position | Name | type | Description | Sample | +| -------- | ------ | ------- | ------------------- | ------ | +| 0 | height | integer | of block height | 1024 | +| 1 | page | integer | page number | 1 | +| 2 | size | integer | page size, max 1000 | 10 | + +#### Returns + +- array: list of the transactions, the object in the list is a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionListOfBlock", + "params": [1024, 1, 10] +} +``` + +Response: [Transaction](#s-transaction) array + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "transactions": [ { TODO: transaction object } ], + "pagination": { + "page": 1, + "size": 10, + "total": 8, + "pages": 1 + } + } +} +``` + +### bp_getTransactionByHash + +Returns information about the transaction specified by its hash. + +#### Parameters + +| Position | Name | type | Description | Sample | +| -------- | ---- | ------ | ----------------------- | ------ | +| 0 | hash | string | hash of the transaction | "TODO" | + +#### Returns + +- object: transaction information object, it's a [Transaction](#s-transaction) + +#### Example + +Request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "bp_getTransactionByHash", + "params": ["TODO"] +} +``` + +Response: [Transaction](#s-transaction) + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + TODO: transaction object + } +} +``` + +## Structure Reference + +Here are some common structure definitions used in the API. + + + +### Block + +The block generated in the CovenantSQL blockchain network. + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------- | +| height | integer | Height of the block | +| hash | string | Hash of the block | +| version | integer | Version number of the block | +| producer | string | Address of the node who generated this block | +| merkle_root | string | Hash of the merkle tree | +| parent | string | Hash of its parent block | +| timestamp | integer | Create time of the block, unix time in nanoseconds | +| timestamp_human | string | Create time of the block, human readable RFC3339 format | +| tx_count | integer | Count of the transactions in this block | + +Sample in JSON format: + +```json +{ + "height": 12, + "hash": "TODO", + "version": 1, + "producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7", + "merkle_root": "TODO", + "parent": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "tx_count": 1 +} +``` + + + +### Transaction + +| Field | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------- | +| block_height | integer | Height of the block this transaction belongs to | +| index | integer | Index of the transaction in the block | +| hash | string | Hash of the transaction data | +| block_hash | string | Hash of the block this transaction belongs to | +| type | integer | Type of the transaction | +| address | string | Account address who signed this transaction | +| timestamp | integer | Create time of the transaction, unix time in nanoseconds | +| timestamp_human | string | Create time of the transaction, human readable RFC3339 format | +| raw | string | Raw content of the transaction data, in JSON format | +| tx | object | Concrete transaction object, see supported [transaction types](#transaction-types) for more | + +Sample in JSON format: + +```json +{ + "block_height": 1, + "index": 0, + "hash": "TODO", + "block_hash": "TODO", + "timestamp": "TODO", + "timestamp_human": "TODO", + "type": 1, + "address": "TODO", + "raw": "TODO", + "tx": { + "field": "TODO" + } +} +``` + +**Supported Transaction Types:** + +- [CreateDatabase](#s-transaction-createdatabase) + +TODO: more types + + + +### Transaction: CreateDatabase + +TODO: more types \ No newline at end of file From f7cb7a4fa96ac948e7f7e824bf8d4a23981ed7c1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:14 +0800 Subject: [PATCH 129/421] New translations proxy.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/proxy.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/proxy.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/proxy.md b/website/translated_docs/zh-CN/version-0.4.0/proxy.md new file mode 100644 index 0000000..7ea1ffa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/proxy.md @@ -0,0 +1,111 @@ +--- +id: version-0.4.0-adapter +title: '📦 CovenantSQL Adapter SDK' +original_id: adapter +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet -listen 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + -config /app/config.yaml -create 1 +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +### NodeJS + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From 24b479c4412e076c0a9523757cf9a13b702f45c5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:16 +0800 Subject: [PATCH 130/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..c3a90f9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.0.6/bck/getting-started-testnet-zh.md @@ -0,0 +1,93 @@ +--- +id: version-0.0.6-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +运行完成后,`cql-utils`会在 `./conf` 目录生成一个配置文件。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `./conf` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ./conf/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -config conf/config.yaml -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From 356e504ec730cdbd27e68d22c6337fd6401eed2a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:17 +0800 Subject: [PATCH 131/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.4.0/qna.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/qna.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/qna.md b/website/translated_docs/zh-CN/version-0.4.0/qna.md new file mode 100644 index 0000000..ff7276d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/qna.md @@ -0,0 +1,6 @@ +--- +id: version-0.4.0-qna +title: '🙋 常见问题解答' +original_id: qna +--- +## TBD \ No newline at end of file From a9e869b169105d4571c0d2151762373f477cf639 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:18 +0800 Subject: [PATCH 132/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/cql.md | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/cql.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/cql.md b/website/translated_docs/zh-CN/version-0.4.0/cql.md new file mode 100644 index 0000000..a934859 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/cql.md @@ -0,0 +1,203 @@ +--- +id: version-0.4.0-cql +title: '🖥️ CQL 命令行工具' +original_id: cql +--- +## 简介 + +本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络。 + +## 查询余额 + +查询余额有两个命令:`cql -get-balance` 和 `cql -token-balance `。其中 `-get-balance` 将返回用户账户中 `Particle` 与 `Wave` 的数量,`-token-balance ` 将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +查看默认余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +查看 Particle 余额: + +```bash +./cql -config conf/config.yaml -token-balance Particle +``` + +输出: + + INFO[0000] Particle balance is: 10000000000000000000 + + +查看 Bitcoin 余额: + +```bash +./cql -config conf/config.yaml -token-balance Bitcoin +``` + +输出: + + INFO[0000] Bitcoin balance is: 0 + + +## 转账 + +转账操作使用 `cql -transfer` 并以 `json` 格式的转账信息为参数。 + +```json +{ + "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount":"1000000 Particle" // 转账金额并带上单位 +} +``` + +其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 + +转账 Particle: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +转账 Wave: + +```bash +./cql -config conf/config.yaml -transfer '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +``` + + INFO[0000] succeed in sending transaction to CovenantSQL + + +查看余额: + +```bash +./cql -config conf/config.yaml -get-balance +``` + +输出: + + INFO[0000] Particle balance is: 9999999999999000000 + INFO[0000] Wave balance is: 9999999999999000000 + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `-get-balance` 或者 `-token-balance ` 确定。 + +## 数据库权限管理 + +#### 访问权限 + +CovenantSQL 数据库有三类库级别权限: + +- `Admin` +- `Write` +- `Read` +- `Void` + +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql -update-perm` 并以 `json` 格式的权限信息为参数: + +```json +{ + "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm":"Write" // 权限内容 +} +``` + +增加写权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +吊销权限: + +```bash +./cql -config conf/config.yaml -update-perm '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +``` + +输出: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 + +为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 + +使用新账户给数据库充值: + +```bash +./cql -config new_user_config/config.yaml -transfer '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +``` + +#### SQL 白名单 + +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 + +增加白名单: + +```shell +./cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read" + } +} +' +``` + +*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* + +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 + +去掉白名单限制: + +```shell +./cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read" + } +} +' +# or +./cql -config conf/config.yaml -update-perm ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read" +} +' +``` + +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file From 4492ef8561347e398c5b5f525d2b01772d8e80c3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:19 +0800 Subject: [PATCH 133/421] New translations native.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/native.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/native.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/native.md b/website/translated_docs/zh-CN/version-0.4.0/native.md new file mode 100644 index 0000000..f2b845e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/native.md @@ -0,0 +1,173 @@ +--- +id: version-0.4.0-native +title: '📦 CovenantSQL Native SDK' +original_id: native +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 8414dfac76ea1e4aa778eb852e501a5d04f51af7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:22 +0800 Subject: [PATCH 134/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/deployment.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/deployment.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/deployment.md b/website/translated_docs/zh-CN/version-0.4.0/deployment.md new file mode 100644 index 0000000..85f8abb --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/deployment.md @@ -0,0 +1,162 @@ +--- +id: version-0.4.0-deployment +title: '🐳 Docker 一键部署' +original_id: deployment +--- +## 使用 CovenantSQL Docker 部署 + +### 安装 Docker + +需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### 下载项目 + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +存为环境变量 + +### 启动 Docker 容器 + +现在有两种方式启动 CovenantSQL 容器: + +1. 使用 Docker Hub 上的公共镜像 +2. 构建 CovenantSQL Docker 镜像 + +> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 + +#### 1. 使用 Docker Hub 上的公共镜像 + +然后直接启动: + +```bash +make start +``` + +#### 2. 构建 CovenantSQL Docker 镜像 + +执行以下的命令在本地运行 CovenantSQL + +```bash +make docker # 从头编译新的镜像 +make start +``` + +### 检查运行状态 + +检查容器状态: + +```bash +docker-compose ps +``` + +确认所有组件都处于 `Up` 的状态 + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## 操作 CovenantSQL + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 1 +``` + +> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -create 2 +``` + +命令会返回创建的数据库实例的连接串 + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### 访问数据库 + +使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 + +```shell +docker exec -it covenantsql_adapter /app/cql -config /app/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +会得到如下输出,并进入 `cql` 交互命令行模式 + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +会得到如下输出 + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 + +### SQLChain Observer + +镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 + +(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) + +#### 在浏览器使用 SQLChain Observer + +我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file From d516e175fca9c16b699e969fba97b67737dc2f03 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:25 +0800 Subject: [PATCH 135/421] New translations quandl.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/quandl.md | 298 ++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/quandl.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/quandl.md b/website/translated_docs/zh-CN/version-0.4.0/quandl.md new file mode 100644 index 0000000..d41d0b6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/quandl.md @@ -0,0 +1,298 @@ +--- +id: version-0.4.0-quandl +title: 基于 Quandl 的金融数据分析 +original_id: quandl +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From 42c53dc43af8f75ae1c4c1905a829ad84676db49 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:26 +0800 Subject: [PATCH 136/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.4.0/usecase.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/usecase.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/usecase.md b/website/translated_docs/zh-CN/version-0.4.0/usecase.md new file mode 100644 index 0000000..6d4193c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/usecase.md @@ -0,0 +1,6 @@ +--- +id: version-0.4.0-usecase +title: 使用案例 +original_id: usecase +--- +## TBD \ No newline at end of file From a995efce5fe943713c12d487b26d756f43b009da Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:28 +0800 Subject: [PATCH 137/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/quickstart.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/quickstart.md b/website/translated_docs/zh-CN/version-0.4.0/quickstart.md new file mode 100644 index 0000000..4794758 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/quickstart.md @@ -0,0 +1,148 @@ +--- +id: version-0.4.0-quickstart +title: '🌏 TestNet 快速开始' +original_id: quickstart +--- +## CovenantSQL 工具包 + +### 工具包简介 + +请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 + +例如,您使用的是: + +- MacOS 平台请下载:[**CovenantSQL-v0.4.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.4.0/CovenantSQL-v0.4.0.osx-amd64.tar.gz) +- Linux 平台请下载:[**CovenantSQL-v0.4.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.4.0/CovenantSQL-v0.4.0.linux-amd64.tar.gz) +- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) + +解压之后,你将得到以下命令行工具,包括:`cql`、`cql-utils` 等。 + +| 工具名 | 介绍 | +| ---------- | --------------------------------------------------- | +| cql | CovenantSQL 的客户端,类似 mysql 命令,用于执行 SQL | +| cql-utils | CovenantSQL 工具箱,用于和主链交互 | +| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | +| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | + +### 测试网快速接入 + +目前,我们已经发布了测试网 v0.4.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 + +测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) ,或者使用以下命令: + +```bash +mkdir conf +wget https://git.io/fhFZe -O conf/config.yaml +wget https://git.io/fhFZv -O conf/private.key +chmod 600 conf/private.key +``` + +**测试网注**: + +> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 + +## 创建并访问 CovenantSQL 数据库 + +### 创建数据库 + +```shell +./cql -config conf/config.yaml -create 1 +``` + +输出: + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 + +> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> +> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 +> 2. 数据库创建请求在 其它出块节点 进行验证和确认 +> 3. SQLChain 的符合条件的 Miner 收到数据库任务 +> 4. SQLChian 组建 Kayak 数据库集群 +> 5. 所有 Miner 准备就绪等待请求 + +### 访问数据库 + +```shell +./cql -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 + +### 数据库 SDK + +- [Golang 开发指引](./development) + +## SQLChain 区块浏览器 + +CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 + +> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 + +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` + +## 创建账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): + +```shell +./cql-utils -tool confgen +``` + +输出: + + Generating key pair... + Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +该命令会为你在~目录下创建一个 `.cql` 目录: + +- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; +- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 + +再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): + +```shell +./cql-utils -tool addrgen -private ~/.cql/private.key +``` + +输出: + +```toml +wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +``` + +你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 + +使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): + +```shell +./cql -config ~/.cql/config.yaml -get-balance +``` + +输出: + + INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" + INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + + +恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 2a794ef5924f63e63643817367940e3b76e728b2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:29 +0800 Subject: [PATCH 138/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/intro.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/intro.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/intro.md b/website/translated_docs/zh-CN/version-0.4.0/intro.md new file mode 100644 index 0000000..dea44aa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/intro.md @@ -0,0 +1,73 @@ +--- +id: version-0.4.0-intro +title: CovenantSQL 介绍 +original_id: intro +--- + + +

+ +

+ +

+ + Go Report Card + + Coverage + + Build Status + + License + + GoDoc + + follow on Twitter + + Join the chat at https://gitter.im/CovenantSQL/CovenantSQL +

+ +CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, + +结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 + +CovenantSQL 具备以下特点: + +* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 +* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 +* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 +* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## CovenantSQL 原理 + +CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: + +* 主链节点: + * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 +* 侧链矿工: + * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 + * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 +* 数据库用户: + * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 + * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 + * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 + +![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) + +* 第一层:**全局共识层**(主链,架构图中的中间环): + * 整个网络中只有一个主链。 + * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 +* 第二层:**SQL 共识层**(子链,架构图中的两边环): + * 每个数据库都有自己独立的子链。 + * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 +* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): + * 每个数据库都有自己独立的分布式引擎。 + * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file From 25607802406f908aa343c88f8d36f0d0a6ea124f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:30 +0800 Subject: [PATCH 139/421] New translations api.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.4.0/api.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/api.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/api.md b/website/translated_docs/zh-CN/version-0.4.0/api.md new file mode 100644 index 0000000..f124f52 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/api.md @@ -0,0 +1,6 @@ +--- +id: version-0.4.0-api +title: '👩🏻‍💻 CovenantSQL API' +original_id: api +--- +## TBD \ No newline at end of file From 65991f1147fc2f0def9aa573b8abe41101864075 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:31 +0800 Subject: [PATCH 140/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.4.0/nav.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.4.0/nav.md diff --git a/website/translated_docs/zh-CN/version-0.4.0/nav.md b/website/translated_docs/zh-CN/version-0.4.0/nav.md new file mode 100644 index 0000000..403ba6e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.4.0/nav.md @@ -0,0 +1,22 @@ +--- +id: version-0.4.0-nav +title: '📖 使用导航' +original_id: nav +--- +## 直接使用测试网 + +[🌏 TestNet 快速开始](./quickstart) + +## 部署私有 CovenantSQL 数据库(搭建私有链) + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) + +## 使用 CovenantSQL 开发应用 + +[📦 CovenantSQL SDK](./development) + +## CovenantSQL 联盟链解决方案 + +正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 247890ab16fd0b82ce1048a83eee15517462127a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 19:26:33 +0800 Subject: [PATCH 141/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../bck/getting-started-testnet-zh.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-testnet-zh.md diff --git a/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-testnet-zh.md new file mode 100644 index 0000000..f7c9caf --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.2.0/bck/getting-started-testnet-zh.md @@ -0,0 +1,93 @@ +--- +id: version-0.2.0-testnet +title: CovenantSQL 测试网快速入门 +original_id: testnet +--- +[CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: + +1. **SQL**: 支持 SQL-92 标准 +2. **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化 +3. **隐私**: 通过加密和授权许可进行访问 +4. **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的 + +我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) + +## 0. 下载 CovenantSQL 工具 + +在 [github](https://github.com/CovenantSQL/CovenantSQL/releases) 下载最新的发行版 + +## 1. 用 `cql-utils` 生成配置文件访问测试网 + +```bash +$ cql-utils -tool confgen +Generating key pair... +Enter master key(press Enter for default: ""): +⏎ +Private key file: conf/private.key +Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd +Generated key pair. +Generating nonce... +nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9} +node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9 +Generated nonce. +Generating config file... +Generated nonce. +``` + +运行完成后,`cql-utils`会在 `./conf` 目录生成一个配置文件。 + +## 2. 用私钥生成钱包地址 + +私钥可以再上一步的 `./conf` 目录中找到,文件名为 `private.key` + +```bash +$ cql-utils -tool addrgen -private ./conf/private.key +Enter master key(default: ""): +⏎ +wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9 +``` + +上述 `4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9` 就是钱包地址 + +## 3. 在水龙头(Faucet)获取 Particle(PTC) + +水龙头(Faucet)的地址为: [CovenantSQL 测试网 Particle(PTC) 水龙头](https://testnet.covenantsql.io/)。 + +完成教程之后,用 `cql` 命令来检查钱包地址的余额: + +```bash +$ cql -config conf/config.yaml -get-balance +INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" +INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" +``` + +当看到 **"stable coin balance is: 100"** 时,表明余额已经为 100。 + +如果您需要更多的 PTC 作为长期测试使用,请联系 。 + +对于有合作的商业伙伴,我们将直接提供 PTC 以供使用。 + +## 4. 使用 `CLI` 创建数据库 + +```bash +$ cql -config conf/config.yaml -create 1 +INFO[0000] the newly created database is: "covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872?use_follower=false&use_leader=true" +``` + +第一行命令中的 `1` 表示申请几个矿工为你的数据库服务。`covenantsql://...` 开头的这个字符串就是创建的数据库访问地址,在 SDK 和 CLI 命令中都需要用此地址,在整个区块链中找到这个数据库。 + +## 5. CLI 和 SDK 的详细文档 + +创建好数据库后,您可以参考以下文档和示例,以便更快的使用CovenantSQL来开发应用。 + +- [CLI 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql/README-zh.md) +- [SDK 文档](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README-zh.md) +- [SDK 示例](https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example) + +## 6. SQLChain 浏览器 + +目前,测试网的数据库时不需要权限的。意味着您可以通过数据库的DSN(数据库访问地址),在[SQLChain 浏览器](https://explorer.dbhub.org)中拿到所有的修改历史和区块信息。 + +更多的测试网技术支持,请访问: + +> [TestNet 发行日志](https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes-zh) \ No newline at end of file From c460c04942300d42caa7311d6150dea1d2f504f8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 22:25:56 +0800 Subject: [PATCH 142/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/deployment.md | 46 ++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/website/translated_docs/zh-CN/deployment.md b/website/translated_docs/zh-CN/deployment.md index 3ef403b..8b5b8c8 100644 --- a/website/translated_docs/zh-CN/deployment.md +++ b/website/translated_docs/zh-CN/deployment.md @@ -64,18 +64,18 @@ docker-compose ps 确认所有组件都处于 `Up` 的状态 ```shell - Name Command State Ports ------------------------------------------------------------------------------------------------------- -covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp -covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp -covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp -covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp -covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp -covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp -covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp -covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp -covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + Name Command State Ports +--------------------------------------------------------------------------------------------------------------------- +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp, 0.0.0.0:12099->4665/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp, 0.0.0.0:12100->4665/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp, 0.0.0.0:12101->4665/tcp +covenantsql_fn_0 ./docker-entry.sh -wsapi :8546 Up 4661/tcp, 0.0.0.0:11110->8546/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp, 0.0.0.0:12102->4665/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp, 0.0.0.0:12103->4665/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp, 0.0.0.0:12104->4665/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh Up 4661/tcp, 0.0.0.0:11108->80/tcp ``` ## 操作 CovenantSQL @@ -85,19 +85,19 @@ covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tc 使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":1}' ``` > 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":2}' ``` 命令会返回创建的数据库实例的连接串 ```shell -covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 ``` ### 访问数据库 @@ -105,16 +105,16 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 ```shell -docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml -no-password -dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 ``` 会得到如下输出,并进入 `cql` 交互命令行模式 ```shell -Connected with driver covenantsql (develop) +Connected with driver covenantsql (develop-34ae741a-20190415135520) Type "help" for help. -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> ``` `cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 @@ -129,23 +129,23 @@ SELECT * FROM test; 会得到如下输出 ```shell -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> CREATE TABLE test (test TEXT); CREATE TABLE -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SHOW TABLES; name ------ test (1 row) -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> INSERT INTO test VALUES("happy"); INSERT -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SELECT * FROM test; test ------- happy (1 row) -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> ``` 使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 From 2249701438e2cb2f33cced8be5486016bd1216c7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:18:21 +0800 Subject: [PATCH 143/421] New translations deployment-en.md (Chinese Simplified) --- .../translated_docs/zh-CN/deployment-en.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 website/translated_docs/zh-CN/deployment-en.md diff --git a/website/translated_docs/zh-CN/deployment-en.md b/website/translated_docs/zh-CN/deployment-en.md new file mode 100644 index 0000000..b94d5df --- /dev/null +++ b/website/translated_docs/zh-CN/deployment-en.md @@ -0,0 +1,162 @@ +--- +id: deployment +title: '🐳 Docker one-line deployment' +--- +## Deploy with CovenantSQL Docker + +### Install Docker + +You need to install docker and docker-compose on your machine to deploy CovenantSQL. + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### Download project + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +### Start Docker container + +There are now two ways to start the CovenantSQL container: + +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image + +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. + +#### 1. Use a public image on Docker Hub + +Then start directly: + +```bash +make start +``` + +#### 2. Build a CovenantSQL Docker image + +Run CovenantSQL locally by executing the following command + +```bash +make docker # compile a new image from source files +make start +``` + +### Check running status + +Check the container status: + +```bash +docker-compose ps +``` + +Confirm that all components are in the `Up` state + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## Operate CovenantSQL + +### Create a database + +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. + +e.g.: creating a single-node database instance + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +The command will return the connection string of the created database instance + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### Accessing the database + +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: + +```shell +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +After that, it will get the following output, and enter the `cql` interactive command line mode + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +After that, it will get the following output: + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line + +### SQLChain Observer + +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. + +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) + +#### Use SQLChain Observer in your browser + +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From a11036a9907343410434b40fac1524261781e351 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:27:22 +0800 Subject: [PATCH 144/421] New translations driver_golang.md (Chinese Simplified) --- .../translated_docs/zh-CN/driver_golang.md | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 website/translated_docs/zh-CN/driver_golang.md diff --git a/website/translated_docs/zh-CN/driver_golang.md b/website/translated_docs/zh-CN/driver_golang.md new file mode 100644 index 0000000..f3f2d45 --- /dev/null +++ b/website/translated_docs/zh-CN/driver_golang.md @@ -0,0 +1,172 @@ +--- +id: driver_golang +title: '📦 Golang' +--- +## 用 Golang 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 + +`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 + +### 兼容性 + +`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 + +### 安装和使用 + +`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` + +可以执行 `go get` 命令进行安装 + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API 文档 + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### 示例 + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // 使用节点配置文件初始化 Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // 连接数据库实例 + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // 写入数据 + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // 查询数据 + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 914da14a43260ded18129d46fe954abad65ba307 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:27:23 +0800 Subject: [PATCH 145/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_js.md | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 website/translated_docs/zh-CN/driver_js.md diff --git a/website/translated_docs/zh-CN/driver_js.md b/website/translated_docs/zh-CN/driver_js.md new file mode 100644 index 0000000..c173d7a --- /dev/null +++ b/website/translated_docs/zh-CN/driver_js.md @@ -0,0 +1,67 @@ +--- +id: driver_js +title: '📦 Javascript' +--- +## 用 NodeJS 使用 CovenantSQL + +NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 + +#### 下载安装 + +可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### 使用 + +使用前需要 [部署 Adapter 工具](./adapter) + +在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: + +```javascript +const config = { + endpoint: 'localhost:11105', // local testnet endpoint without https + database: `${DSN}`, // your DB id created by `cql` tools + bypassPem: true // bypass https config +} +``` + +这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 + +接着连通之后则可进行链上数据库的增删改查: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From 495012f086086dc300d9679c7794697d2d5d16b3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:27:24 +0800 Subject: [PATCH 146/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 website/translated_docs/zh-CN/adpater.md diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md new file mode 100644 index 0000000..dd7ceb8 --- /dev/null +++ b/website/translated_docs/zh-CN/adpater.md @@ -0,0 +1,52 @@ +--- +id: adapter +title: '📦 CovenantSQL Adapter SDK' +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + create -config /app/config.yaml -wait-tx-confirm '{"node": 1}' +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +1. [Java](./driver_java) +2. [Python](./driver_python) +3. [NodeJS](./driver_js) \ No newline at end of file From 534a743b0d627f98183cb0cf63757d1f7b8cb46f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:27:26 +0800 Subject: [PATCH 147/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 68 ++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 website/translated_docs/zh-CN/driver_java.md diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md new file mode 100644 index 0000000..6e185d2 --- /dev/null +++ b/website/translated_docs/zh-CN/driver_java.md @@ -0,0 +1,68 @@ +--- +id: driver_java +title: '📦 Java' +--- +## 用 Java 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Java SDK`,可通过 `Adapter` 工具转换协议访问数据库实例。 + +`Java SDK` 遵守 `Java` 标准的 `JDBC4` 接口定义,能够使用常见的 `ORM` 例如 `MyBatis` 进行使用。 + +### 兼容性 + +`Java SDK` 目前只兼容 `Java 1.7+` 的 `JDK` 版本。 + +### 安装和使用 + +使用 `Java SDK` 需要 [部署 Adapter 工具](./adapter)。 + +然后通过 `jdbc:covenantsql:///` URI,将其中的 `adapter_endpoint` 替换为 adapter 的地址,`database_id` 替换为数据库的 DSN 串访问数据库实例。 + +#### Maven + +```xml + + + mvn-repo + https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo + + true + + + true + + + +``` + +```xml + + + io.covenantsql + covenantsql-java + 1.0-SNAPSHOT + + +``` + +#### Gradle + +```gradle +repositories { + maven { + url 'https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo' + } +} + +dependencies { + compile 'io.covenantsql:covenantsql-java-connector:1.0-SNAPSHOT' +} +``` + +### 示例 + +1. [JDBC示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +3. [大型项目示例](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From 2b8819130bd9b3232f73ac5f26650886c94c3bf2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 15 Apr 2019 23:27:27 +0800 Subject: [PATCH 148/421] New translations driver_python.md (Chinese Simplified) --- .../translated_docs/zh-CN/driver_python.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 website/translated_docs/zh-CN/driver_python.md diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md new file mode 100644 index 0000000..b86897a --- /dev/null +++ b/website/translated_docs/zh-CN/driver_python.md @@ -0,0 +1,53 @@ +--- +id: driver_python +title: '📦 Python' +--- +## 用 Python 使用 CovenantSQL + +开发者可以通过 [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) 来使用 CovenantSQL。 + +### 兼容性 + +`Python SDK` 目前只兼容 `python 3.4+` + +### 安装和使用 + +使用 `Python SDK` 需要 [部署 Adapter 工具](./adapter)。 + +使用 pip 安装 PyCovenantSQL + +```shell +$ python3 -m pip install PyCovenantSQL +``` + +### 示例 + +将 `adapter_host` 替换为 adapter 地址,`adapter_port` 替换为 adapter 的端口,adapter + +```python +import pycovenantsql + +# Connect to the database +connection = pycovenantsql.connect(host='', + port=, + database='' + ) + +try: + with connection.cursor() as cursor: + # Create a new record + sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)" + cursor.execute(sql, ('webmaster@python.org', 'very-secret')) + + # connection is autocommit. No need to commit in any case. + # connection.commit() + + with connection.cursor() as cursor: + # Read a single record + sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s" + cursor.execute(sql, ('webmaster@python.org',)) + result = cursor.fetchone() + print(result) +finally: + connection.close() +``` \ No newline at end of file From 91ab923320c02328fffdde1653e94a7f7eb573f2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 16:29:00 +0800 Subject: [PATCH 149/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment.md | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md index 705df6e..0b2f381 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -65,18 +65,18 @@ docker-compose ps 确认所有组件都处于 `Up` 的状态 ```shell - Name Command State Ports ------------------------------------------------------------------------------------------------------- -covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp -covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp -covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp -covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp -covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp -covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp -covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp -covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp -covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + Name Command State Ports +--------------------------------------------------------------------------------------------------------------------- +covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp +covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp, 0.0.0.0:12099->4665/tcp +covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp, 0.0.0.0:12100->4665/tcp +covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp, 0.0.0.0:12101->4665/tcp +covenantsql_fn_0 ./docker-entry.sh -wsapi :8546 Up 4661/tcp, 0.0.0.0:11110->8546/tcp +covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp, 0.0.0.0:12102->4665/tcp +covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp, 0.0.0.0:12103->4665/tcp +covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp, 0.0.0.0:12104->4665/tcp +covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer ./docker-entry.sh Up 4661/tcp, 0.0.0.0:11108->80/tcp ``` ## 操作 CovenantSQL @@ -86,19 +86,19 @@ covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tc 使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":1}' ``` > 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":2}' ``` 命令会返回创建的数据库实例的连接串 ```shell -covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 ``` ### 访问数据库 @@ -106,16 +106,16 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 ```shell -docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml -no-password -dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 ``` 会得到如下输出,并进入 `cql` 交互命令行模式 ```shell -Connected with driver covenantsql (develop) +Connected with driver covenantsql (develop-34ae741a-20190415135520) Type "help" for help. -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> ``` `cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 @@ -130,23 +130,23 @@ SELECT * FROM test; 会得到如下输出 ```shell -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> CREATE TABLE test (test TEXT); CREATE TABLE -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SHOW TABLES; name ------ test (1 row) -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> INSERT INTO test VALUES("happy"); INSERT -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SELECT * FROM test; test ------- happy (1 row) -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> ``` 使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 From d761c71e40df0f5308b133cfa59b61e9c267db30 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 16:48:35 +0800 Subject: [PATCH 150/421] New translations adpater.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/adpater.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/adpater.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md new file mode 100644 index 0000000..85992aa --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -0,0 +1,53 @@ +--- +id: version-0.5.0-adapter +title: '📦 CovenantSQL Adapter SDK' +original_id: adapter +--- +# 通过 Adapter 使用 CovenantSQL + +## 简介 + +`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 + +## 安装和使用 + +首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) + +### Docker 运行 Adapter + +下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet 0.0.0.0:4661 +``` + +### 创建数据库 + +使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 + +```shell +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + create -config /app/config.yaml -wait-tx-confirm '{"node": 1}' +``` + +命令会返回创建的数据库实例的连接串(DSN) + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +## 主流语言 Driver 的使用 + +1. [Java](./driver_java) +2. [Python](./driver_python) +3. [NodeJS](./driver_js) \ No newline at end of file From d7cfd9b9b406377c5c1828f81145a6771ad0cca0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 16:48:36 +0800 Subject: [PATCH 151/421] New translations deployment-en.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment-en.md | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/deployment-en.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md new file mode 100644 index 0000000..adfe539 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md @@ -0,0 +1,163 @@ +--- +id: version-0.5.0-deployment +title: '🐳 Docker one-line deployment' +original_id: deployment +--- +## Deploy with CovenantSQL Docker + +### Install Docker + +You need to install docker and docker-compose on your machine to deploy CovenantSQL. + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### Download project + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +### Start Docker container + +There are now two ways to start the CovenantSQL container: + +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image + +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. + +#### 1. Use a public image on Docker Hub + +Then start directly: + +```bash +make start +``` + +#### 2. Build a CovenantSQL Docker image + +Run CovenantSQL locally by executing the following command + +```bash +make docker # compile a new image from source files +make start +``` + +### Check running status + +Check the container status: + +```bash +docker-compose ps +``` + +Confirm that all components are in the `Up` state + +```shell + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp +``` + +## Operate CovenantSQL + +### Create a database + +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. + +e.g.: creating a single-node database instance + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes + +```shell +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +The command will return the connection string of the created database instance + +```shell +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +### Accessing the database + +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: + +```shell +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +After that, it will get the following output, and enter the `cql` interactive command line mode + +```shell +Connected with driver covenantsql (develop) +Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + +```sql +CREATE TABLE test (test TEXT); +SHOW TABLES; +INSERT INTO test VALUES("happy"); +SELECT * FROM test; +``` + +After that, it will get the following output: + +```shell +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); +CREATE TABLE +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name +------ + test +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); +INSERT +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test +------- + happy +(1 row) + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> +``` + +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line + +### SQLChain Observer + +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. + +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) + +#### Use SQLChain Observer in your browser + +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From ddb2c17ed7fdc3eedd4cba9aff63b3733faeb05e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 16:48:38 +0800 Subject: [PATCH 152/421] New translations driver_java.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_java.md | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/driver_java.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md new file mode 100644 index 0000000..bb03333 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -0,0 +1,69 @@ +--- +id: version-0.5.0-driver_java +title: '📦 Java' +original_id: driver_java +--- +## 用 Java 使用 CovenantSQL + +### 简介 + +`CovenantSQL` 提供了 `Java SDK`,可通过 `Adapter` 工具转换协议访问数据库实例。 + +`Java SDK` 遵守 `Java` 标准的 `JDBC4` 接口定义,能够使用常见的 `ORM` 例如 `MyBatis` 进行使用。 + +### 兼容性 + +`Java SDK` 目前只兼容 `Java 1.7+` 的 `JDK` 版本。 + +### 安装和使用 + +使用 `Java SDK` 需要 [部署 Adapter 工具](./adapter)。 + +然后通过 `jdbc:covenantsql:///` URI,将其中的 `adapter_endpoint` 替换为 adapter 的地址,`database_id` 替换为数据库的 DSN 串访问数据库实例。 + +#### Maven + +```xml + + + mvn-repo + https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo + + true + + + true + + + +``` + +```xml + + + io.covenantsql + covenantsql-java + 1.0-SNAPSHOT + + +``` + +#### Gradle + +```gradle +repositories { + maven { + url 'https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo' + } +} + +dependencies { + compile 'io.covenantsql:covenantsql-java-connector:1.0-SNAPSHOT' +} +``` + +### 示例 + +1. [JDBC示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +3. [大型项目示例](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From e6ea738357271d1f57ccff842ae36785752249aa Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 16:48:39 +0800 Subject: [PATCH 153/421] New translations driver_python.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_python.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/driver_python.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md new file mode 100644 index 0000000..af9f079 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -0,0 +1,54 @@ +--- +id: version-0.5.0-driver_python +title: '📦 Python' +original_id: driver_python +--- +## 用 Python 使用 CovenantSQL + +开发者可以通过 [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) 来使用 CovenantSQL。 + +### 兼容性 + +`Python SDK` 目前只兼容 `python 3.4+` + +### 安装和使用 + +使用 `Python SDK` 需要 [部署 Adapter 工具](./adapter)。 + +使用 pip 安装 PyCovenantSQL + +```shell +$ python3 -m pip install PyCovenantSQL +``` + +### 示例 + +将 `adapter_host` 替换为 adapter 地址,`adapter_port` 替换为 adapter 的端口,adapter + +```python +import pycovenantsql + +# Connect to the database +connection = pycovenantsql.connect(host='', + port=, + database='' + ) + +try: + with connection.cursor() as cursor: + # Create a new record + sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)" + cursor.execute(sql, ('webmaster@python.org', 'very-secret')) + + # connection is autocommit. No need to commit in any case. + # connection.commit() + + with connection.cursor() as cursor: + # Read a single record + sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s" + cursor.execute(sql, ('webmaster@python.org',)) + result = cursor.fetchone() + print(result) +finally: + connection.close() +``` \ No newline at end of file From 7426203b33ccf405900adc644bb1d9e0d60b81de Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 16 Apr 2019 22:30:12 +0800 Subject: [PATCH 154/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 568 +++++++++++++++++++++++---- 1 file changed, 498 insertions(+), 70 deletions(-) diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md index be990f0..8757ca2 100644 --- a/website/translated_docs/zh-CN/cql.md +++ b/website/translated_docs/zh-CN/cql.md @@ -1,111 +1,299 @@ --- id: cql -title: '🖥️ CQL 命令行工具' +title: '🖥️ CQL 命令行工具集' --- ## 简介 -本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络, 并将 `cql` 可执行文件保存在 `PATH` 目录。 +CovenantSQL 为终端用户提供 `cql` 命令行工具集,用于对用户账号、钱包以及名下的数据库进行便捷的管理和访问操作。~~工具下载地址见 [release](https://github.com/CovenantSQL/CovenantSQL/releases) 页面。请将 `cql` 二进制解压到自己系统 PATH 路径里以方便调用。~~(补充:使用包管理工具安装 `cql`)。 -### 配置文件 +### 账号私钥和配置文件 -`cql`命令依赖配置文件`config.yaml`和私钥文件`private.key`。这两个文件如果使用`cql generate config`命令生成,会默认放在`~/.cql/`目录下。在此目录下时,`cql`所有子命令的`-config`参数均可以省略不填写。 +运行 `cql` 依赖私钥文件 `private.key` 和配置文件 `config.yaml`,其中: -### Master key +- `private.key`:生成用户账户时所分配的私钥,请务必妥善保管好这个私钥 +- `config.yaml`:主要用于配置 `cql` 命令要连接的 CovenantSQL 网络(如 TestNet 或用户使用 [Docker 一键部署](deployment)的网络) -`private.key`文件在生成时需要输入密码,`cql`命令会自动请求输入master key (密码)。 如果想在脚本中使用,可以在子命令后面增加`-password your_master_key`,空密码时用`-no-password`参数。 +出于安全方面的考虑,私钥文件通常需要使用主密码进行加密。主密码在创建账号时由用户输入,之后由用户自行记忆或保管,而不会保存到配置文件中。当需要使用到私钥的时候,`cql` 命令会要求用户输入主密码以解开私钥文件。 -## 查询余额 +### 子命令通用参数 -查询余额的命令是:`cql wallet -balance `。其中`token_type`设置为`all`时将返回用户账户中 `Particle` 与 `Wave` 的数量,其他关键词将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: +以下列出子命令中使用到的通用参数: -- `Particle` -- `Wave` -- `Bitcoin` -- `Ether` -- `EOS` +```bash + -bypass-signature + 禁用签名和验签,仅用于开发者测试 + -config string + 指定配置文件路径,默认值为 "~/.cql/config.yaml" + -no-password + 使用空白主密码加密私钥 + -password string + 私钥主密码(不安全,仅用于调试或安全环境下的脚本模式) +``` + +注意,因为私钥文件的路径是在配置文件中设定的,默认值为相对路径 `./private.key`,即配置文件的同一目录下,所以我们通常把私钥和配置文件放置到同一目录下,而不设置单独的参数来指定私钥文件。 + +## 账号管理 + +对于 TestNet 环境,我们提供了一个公用的测试账号私钥及配置文件用于快速接入测试,详情请参见 [CovenantSQL TestNet](quickstart) 快速上手教程。另外你也可以选择参照如下教程在本地创建新账号。 + +### 创建新账号 -查看默认余额: +子命令 `generate` 在指定目录生成私钥及指向 TestNet 的配置文件,示例: ```bash -cql wallet -balance all -config conf/config.yaml +cql generate config ``` +> 目前默认生成的配置文件指向测试网,还需要提供生成指向 Docker 一键部署网络的配置方法。 + +指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 + 输出: - INFO[0000] Particle balance is: 10000000000000000000 - INFO[0000] Wave balance is: 10000000000000000000 - +```bash +Generating key pair... +Enter master key(press Enter for default: ""): +Private key file: ~/.cql/private.key +Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 +Generated key pair. +Generating nonce... +INFO[0075] cpu: 4 +INFO[0075] position: 3, shift: 0x0, i: 3 +INFO[0075] position: 1, shift: 0x0, i: 1 +INFO[0075] position: 0, shift: 0x0, i: 0 +INFO[0075] position: 2, shift: 0x0, i: 2 +nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} +node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 +Generated nonce. +Generating config file... +Generated nonce. +``` + +### 获取私钥文件的公钥 -查看 Particle 余额: +子命令 `generate` 也可以用来获取已经存在的私钥文件对应的公钥十六进制串。示例: ```bash -cql wallet -balance Particle -config conf/config.yaml +cql generate public ``` 输出: - INFO[0000] Particle balance is: 10000000000000000000 - +```bash +Enter master key(press Enter for default: ""): + +INFO[0011] init config success path=/home/levente/.cql/private.key +INFO[0011] use public key in config file: /home/levente/.cql/config.yaml +Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 +``` + +> 这一功能实际使用过程中暂时不会用到 + +### 子命令 `generate` 完整参数 + +通用参数部分参考 [子命令通用参数](#子命令通用参数),以下介绍其他子命令时不再另外说明。 -查看 Bitcoin 余额: +特殊地,在使用 `cql generate config` 命令生成新账号配置时,`-config`、`-no-password` 和 `-password` 等参数实际作用于将要生成的新私钥和配置文件,而不是要读取的文件。 ```bash -cql wallet -balance Bitcoin -config conf/config.yaml +usage: cql generate [参数]... config | public + +生成新私钥及配置文件,或获取指定配置的私钥文件对应的公钥。 + +Params: + 没有额外参数 +``` + +### 计算 Node ID + +子命令 `idminer` 用于计算指定配置文件(对应的私钥)的 Node ID(Node ID 的相关知识请参考[链接](terms#Node-ID))。示例: + +```bash +cql idminer ``` 输出: - INFO[0000] Bitcoin balance is: 0 - +```bash +INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 +Enter master key(press Enter for default: ""): + +INFO[0008] init config success path=/home/levente/.cql/config.yaml +INFO[0008] use public key in config file: /home/levente/.cql/config.yaml +INFO[0008] cpu: 8 +INFO[0008] position: 3, shift: 0x20, i: 7 +INFO[0008] position: 0, shift: 0x0, i: 0 +INFO[0008] position: 3, shift: 0x0, i: 6 +INFO[0008] position: 1, shift: 0x0, i: 2 +INFO[0008] position: 2, shift: 0x0, i: 4 +INFO[0008] position: 1, shift: 0x20, i: 3 +INFO[0008] position: 2, shift: 0x20, i: 5 +INFO[0008] position: 0, shift: 0x20, i: 1 +nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} +node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e +``` + +> 这一功能实际使用过程中暂时不会用到 + +### 子命令 `idminer` 完整参数 -## 转账 +```bash +usage: cql idminer [-config file] [-difficulty number] [-loop false] + +为指定配置的私钥文件计算新的 Node ID。 + +Params: + -difficulty int + 生成 Node ID 的难度要求,默认值为 24 + -loop + 循环计算以取得更高难度的 Node ID +``` + +## 钱包管理 + +### 查看钱包地址 -转账操作使用 `cql transfer` 并以 `json` 格式的转账信息为参数。 +在配置好账号以后,可以通过 `wallet` 子命令来获取账号的钱包地址: + +```bash +cql wallet +``` + +输出: + +```bash +Enter master key(press Enter for default: ""): + +wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 +``` + +这里可以看到我们用于测试的账号私钥文件对应的钱包地址是 `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`。 + +### 查看钱包余额 + +获得钱包地址之后,就可以使用 `wallet` 子命令来查看你的钱包余额了。目前 CovenantSQL 支持的代币类型为以下 5 种: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +其中 `Particle` 和 `Wave` 为 CovenantSQL 默认使用的代币,查看默认代币余额的命令为: + +```bash +cql wallet -balance all +``` + +输出: + +```bash +INFO[0000] Particle balance is: 10000000000000000000 +INFO[0000] Wave balance is: 10000000000000000000 +``` + +也可以单独指定代币类型,如查看 `Bitcoin` 余额: + +```bash +cql wallet -balance Bitcoin +``` + +输出: + +```bash +INFO[0000] Bitcoin balance is: 0 +``` + +### 向其他账号转账 + +从 [TestNet](quickstart) 获得代币或 [Docker 一键部署](deployment)的网络获得代币后,可以使用 `transfer` 命令来向其他账号转账。转账操作使用 `json` 格式的转账信息作为参数,例如: ```json { - "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 - "amount":"1000000 Particle" // 转账金额并带上单位 + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount": "1000000 Particle" // 转账金额并带上单位 } ``` 其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 -转账 Particle: +把以上参数传给 `transfer` 子命令来进行转账: ```bash -cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` + +注意,以上输出信息只说明交易请求已经成功发送至 CovenantSQL 网络,需要等待 BP 节点执行并确认交易后才能实际生效。交易能否成功、何时成功可以通过执行 `cql wallet -balance ` 来确定,也可以在执行命令时添加 `-wait-tx-confirm` 参数来让 `cql` 命令查询到执行结果之后再退出。 -转账 Wave: +### 子命令 `wallet` 完整参数 ```bash -cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +usage: cql wallet [-config file] [-balance token_type] + +查看账号钱包地址和代币余额。 +示例: + cql wallet + cql wallet -balance Particle + cql wallet -balance all + +Params: + -balance string + 获取当前账号中指定代币类型的余额 ``` - INFO[0000] succeed in sending transaction to CovenantSQL - +### 子命令 `transfer` 完整参数 -查看余额: +```bash +usage: cql transfer [-config file] [-wait-tx-confirm] meta_json + +向目标账号地址进行转账。输入参数为 JSON 格式的转账交易数据。 +示例: + cql transfer '{"addr": "your_account_addr", "amount": "100 Particle"}' + +由于 CovenantSQL 是区块链上的数据库,在交易生效之前你可能需要等待执行确认。 +示例: + cql transfer -wait-tx-confirm '{"addr": "your_account_addr", "amount": "100 Particle"}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +## 数据库管理 + +### 创建数据库 + +创建数据库与 `transfer` 子命令类似使用 `json` 格式的输入参数,创建由一个节点组成的数据库: ```bash -cql wallet -balance all -config conf/config.yaml +cql create '{"node": 1}' ``` 输出: - INFO[0000] Particle balance is: 9999999999999000000 - INFO[0000] Wave balance is: 9999999999999000000 - +```bash +Enter master key(press Enter for default: ""): + +covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` -注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `cql wallet -balance ` 确定。 +注意这里生成的 `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 即为数据库的连接字符串(dsn),其中 `covenantsql` 为数据库协议字段,一般也可以缩写为 `cql`;`//` 后的十六进制串为数据库地址,可以在 `transfer` 子命令中作为收款地址使用。 -## 数据库权限管理 +子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 + +关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 + +### ~~删除数据库~~ + +~~未实现。~~ + +### 数据库权限管理 #### 访问权限 @@ -116,56 +304,60 @@ CovenantSQL 数据库有三类库级别权限: - `Read` - `Void` -其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql grant` 并以 `json` 格式的权限信息为参数: +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。 + +假设我们用默认账号创建好了数据库 `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5`,在目录 `account2` 下创建好新账号配置,账号地址为 `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`,现在用默认账号给新账号授权已经创建好的数据库的访问权限,同样使用 `json` 格式的授权信息为参数: ```json { - "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 - "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 - "perm":"Write" // 权限内容 + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm": "Read,Write" // 权限内容,多个权限用英文逗号隔开 } ``` -增加写权限: +把以上参数传给 `grant` 子命令来增加读写权限: ```bash -cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` 吊销权限: ```bash -cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` -注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 +子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 -为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 +由于目前每个数据库实例分别为每个用户独立计费,所以为数据库添加新的账户权限后,需要以新账户身份向该数据库转押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 使用新账户给数据库充值: ```bash -cql transfer -config new_user_config/config.yaml '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' ``` #### SQL 白名单 -CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除或更新操作。 增加白名单: -```shell -cql -config conf/config.yaml -update-perm ' +```bash +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", @@ -174,7 +366,7 @@ cql -config conf/config.yaml -update-perm ' "SELECT COUNT(1) FROM a", "SELECT * FROM a WHERE id = ? LIMIT 1" ], - "role": "Read" + "role": "Read,Write" } } ' @@ -182,29 +374,265 @@ cql -config conf/config.yaml -update-perm ' *白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* -设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a` 的总数据量。 去掉白名单限制: -```shell -cql -config conf/config.yaml -update-perm ' +```bash +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": { "patterns": nil, - "role": "Read" + "role": "Read,Write" } } ' # or -cql -config conf/config.yaml -update-perm ' +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", - "perm": "Read" + "perm": "Read,Write" } ' ``` -将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 + +### 子命令 `create` 完整参数 + +```bash +usage: cql create [-config file] [-wait-tx-confirm] db_meta_json + +为当前账号创建数据库实例,输入参数为 JSON 格式的创建交易数据,其中节点数 node 为必带字段。 +示例: + cql create '{"node": 2}' + +完整的 db_meta_json 字段解释如下: + targetminers []string // 目标节点的账号地址 + node int // 目标节点数 + space int // 需要的硬盘空间,0 为任意 + memory int // 需要的内存空间,0 为任意 + loadavgpercpu float // 需要的 CPU 资源占用,0 为任意 + encryptionkey string // 落盘加密密钥 + useeventualconsistency bool // 各个数据库节点之间是否使用最终一致性同步 + consistencylevel float // 一致性级别,通过 node*consistencylevel 得到强同步的节点数 + isolationlevel int // 单个节点上的隔离级别,默认级别为线性级别 + +由于 CovenantSQL 是区块链上的数据库,在真正访问数据库之前你可能需要等待创建请求的执行确认以及在数据库节点上的实际创建。 +示例: + cql create -wait-tx-confirm '{"node": 2}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +### 子命令 `drop` 完整参数 + +```bash +usage: cql drop [-config file] [-wait-tx-confirm] dsn/dbid + +通过数据库的连接字符串或账号地址来删除数据库。 +示例: + cql drop the_dsn_of_your_database + +由于 CovenantSQL 是区块链上的数据库,在删除操作生效之前你可能需要等待删除请求的执行确认以及在数据库节点上的实际执行。 +示例: + cql drop -wait-tx-confirm the_dsn_of_your_database + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +### 子命令 `grant` 完整参数 + +```bash +usage: cql grant [-config file] [-wait-tx-confirm] permission_meta_json + +为指定账号进行数据库权限授权。 +示例: + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + +由于 CovenantSQL 是区块链上的数据库,在授权操作生效之前你可能需要等待授权请求的执行确认以及在数据库节点上的实际更新。 +示例 + cql grant -wait-tx-confirm '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +## 访问数据库 + +完成数据库的创建后,就可以使用 `console` 子命令来对数据库进行交互式的命令行访问了: + +```bash +cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +输出 + +```bash +Enter master key(press Enter for default: ""): + +INFO[0010] init config success path=/home/levente/.cql/config.yaml +INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" +Connected with driver covenantsql (develop-34ae741a-20190416184528) +Type "help" for help. + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +或者使用以授权的账号来连接: + +```bash +cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +输出 + +```bash +Enter master key(press Enter for default: ""): + +INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml +INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" +Connected with driver covenantsql (develop-34ae741a-20190416184528) +Type "help" for help. + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +交互式访问示例: + +```bash +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); +CREATE TABLE +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); +INSERT +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; +c1 +---- +1 +2 +3 +(3 rows) + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +### 子命令 `console` 完整参数 + +子命令 `console` 同时也支持在后台启动 `adapter` 和 `explorer` 服务,关于这些服务的相关说明请参考 [本地服务](#本地服务) 的相关章节。 + +```bash +usage: cql console [-config file] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] + +为 CovenantSQL 运行交互式的命令行访问。 +示例: + cql console -dsn the_dsn_of_your_database + +另外也可以通过 -command 参数来直接运行 SQL 查询语句或通过 -file 参数来从文件读取查询语句。 +在指定了这些参数的情况下 `console` 子命令将会直接执行命令后退出,而不会进入交互式的命令行模式。 +示例: + cql console -dsn the_dsn_of_your_database -command "create table test1(test2 int);" + +Params: + -adapter string + 指定数据库子链的 adapter 服务器的监听地址 + -command string + 执行单条 SQL 语句并退出 + -dsn string + 数据库连接字符串 + -explorer string + 指定数据库子链的 explorer 服务器监听地址 + -file string + 执行 SQL 脚本中的语句并退出 + -no-rc + 启动时不加载 .rc 初始脚本 + -out string + 指定输出文件 + -single-transaction + 在非交互模式下使用单个事务执行所有语句 + -variable value + 设置环境变量 +``` + +## 本地服务 + +### Explorer 完整参数 + +```bash +usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address + +为数据库子链运行 adapter 服务器。 +示例: + cql explorer 127.0.0.1:8546 + +Params: + -bg-log-level string + 后台服务日志级别 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +### Mirror 完整参数 + +```bash +usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address + +为数据库子链运行 mirror 服务器。 +示例: + cql mirror database_id 127.0.0.1:9389 + +Params: + -bg-log-level string + 后台服务日志级别 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +### Adapter 完整参数 + +```bash +usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address + +为数据库子链运行 adapter 服务器。 +示例: + cql adapter 127.0.0.1:7784 + +Params: + -bg-log-level string + 后台服务日志级别 + -mirror string + 指定镜像 adapter 服务器地址 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +## 高级使用 + +### RPC 完整参数 + +```bash +usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request + +向目标服务器发送 RPC 请求。 +示例: + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + +Params: + -endpoint string + 目标 RPC 服务地址 + -name string + 目标 RPC 方法名 + -req string + RPC 请求数据,JSON 格式 + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` \ No newline at end of file From 8a2bccc43e0c9ab7cc8f55c32bafc034dc6bc80a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 10:24:23 +0800 Subject: [PATCH 155/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md index 8757ca2..a58841e 100644 --- a/website/translated_docs/zh-CN/cql.md +++ b/website/translated_docs/zh-CN/cql.md @@ -46,7 +46,7 @@ cql generate config > 目前默认生成的配置文件指向测试网,还需要提供生成指向 Docker 一键部署网络的配置方法。 -指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 +指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 输出: @@ -287,7 +287,7 @@ covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 -关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 +关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 ### ~~删除数据库~~ From d5b0fec3a7ddd9cbfc5c3c9a1e084ab4f5beee7c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 10:24:35 +0800 Subject: [PATCH 156/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql.md | 568 +++++++++++++++--- 1 file changed, 498 insertions(+), 70 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md index 0c7c33d..7fdc6ed 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -1,112 +1,300 @@ --- id: version-0.5.0-cql -title: '🖥️ CQL 命令行工具' +title: '🖥️ CQL 命令行工具集' original_id: cql --- ## 简介 -本文将介绍如何使用 `cql` 进行查询、转账和数据库权限管理。在使用 `cql` 前请先确认已接入 [CovenantSQL TestNet](quickstart) 或者在本地使用 [Docker 一键部署](development)的网络, 并将 `cql` 可执行文件保存在 `PATH` 目录。 +CovenantSQL 为终端用户提供 `cql` 命令行工具集,用于对用户账号、钱包以及名下的数据库进行便捷的管理和访问操作。~~工具下载地址见 [release](https://github.com/CovenantSQL/CovenantSQL/releases) 页面。请将 `cql` 二进制解压到自己系统 PATH 路径里以方便调用。~~(补充:使用包管理工具安装 `cql`)。 -### 配置文件 +### 账号私钥和配置文件 -`cql`命令依赖配置文件`config.yaml`和私钥文件`private.key`。这两个文件如果使用`cql generate config`命令生成,会默认放在`~/.cql/`目录下。在此目录下时,`cql`所有子命令的`-config`参数均可以省略不填写。 +运行 `cql` 依赖私钥文件 `private.key` 和配置文件 `config.yaml`,其中: -### Master key +- `private.key`:生成用户账户时所分配的私钥,请务必妥善保管好这个私钥 +- `config.yaml`:主要用于配置 `cql` 命令要连接的 CovenantSQL 网络(如 TestNet 或用户使用 [Docker 一键部署](deployment)的网络) -`private.key`文件在生成时需要输入密码,`cql`命令会自动请求输入master key (密码)。 如果想在脚本中使用,可以在子命令后面增加`-password your_master_key`,空密码时用`-no-password`参数。 +出于安全方面的考虑,私钥文件通常需要使用主密码进行加密。主密码在创建账号时由用户输入,之后由用户自行记忆或保管,而不会保存到配置文件中。当需要使用到私钥的时候,`cql` 命令会要求用户输入主密码以解开私钥文件。 -## 查询余额 +### 子命令通用参数 -查询余额的命令是:`cql wallet -balance `。其中`token_type`设置为`all`时将返回用户账户中 `Particle` 与 `Wave` 的数量,其他关键词将返回用户账户中特定 `token_type` 的 token 数量。目前系统支持的 `token_type` 有: +以下列出子命令中使用到的通用参数: -- `Particle` -- `Wave` -- `Bitcoin` -- `Ether` -- `EOS` +```bash + -bypass-signature + 禁用签名和验签,仅用于开发者测试 + -config string + 指定配置文件路径,默认值为 "~/.cql/config.yaml" + -no-password + 使用空白主密码加密私钥 + -password string + 私钥主密码(不安全,仅用于调试或安全环境下的脚本模式) +``` + +注意,因为私钥文件的路径是在配置文件中设定的,默认值为相对路径 `./private.key`,即配置文件的同一目录下,所以我们通常把私钥和配置文件放置到同一目录下,而不设置单独的参数来指定私钥文件。 + +## 账号管理 + +对于 TestNet 环境,我们提供了一个公用的测试账号私钥及配置文件用于快速接入测试,详情请参见 [CovenantSQL TestNet](quickstart) 快速上手教程。另外你也可以选择参照如下教程在本地创建新账号。 + +### 创建新账号 -查看默认余额: +子命令 `generate` 在指定目录生成私钥及指向 TestNet 的配置文件,示例: ```bash -cql wallet -balance all -config conf/config.yaml +cql generate config ``` +> 目前默认生成的配置文件指向测试网,还需要提供生成指向 Docker 一键部署网络的配置方法。 + +指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 + 输出: - INFO[0000] Particle balance is: 10000000000000000000 - INFO[0000] Wave balance is: 10000000000000000000 - +```bash +Generating key pair... +Enter master key(press Enter for default: ""): +Private key file: ~/.cql/private.key +Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 +Generated key pair. +Generating nonce... +INFO[0075] cpu: 4 +INFO[0075] position: 3, shift: 0x0, i: 3 +INFO[0075] position: 1, shift: 0x0, i: 1 +INFO[0075] position: 0, shift: 0x0, i: 0 +INFO[0075] position: 2, shift: 0x0, i: 2 +nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} +node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 +Generated nonce. +Generating config file... +Generated nonce. +``` + +### 获取私钥文件的公钥 -查看 Particle 余额: +子命令 `generate` 也可以用来获取已经存在的私钥文件对应的公钥十六进制串。示例: ```bash -cql wallet -balance Particle -config conf/config.yaml +cql generate public ``` 输出: - INFO[0000] Particle balance is: 10000000000000000000 - +```bash +Enter master key(press Enter for default: ""): + +INFO[0011] init config success path=/home/levente/.cql/private.key +INFO[0011] use public key in config file: /home/levente/.cql/config.yaml +Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 +``` + +> 这一功能实际使用过程中暂时不会用到 + +### 子命令 `generate` 完整参数 + +通用参数部分参考 [子命令通用参数](#子命令通用参数),以下介绍其他子命令时不再另外说明。 -查看 Bitcoin 余额: +特殊地,在使用 `cql generate config` 命令生成新账号配置时,`-config`、`-no-password` 和 `-password` 等参数实际作用于将要生成的新私钥和配置文件,而不是要读取的文件。 ```bash -cql wallet -balance Bitcoin -config conf/config.yaml +usage: cql generate [参数]... config | public + +生成新私钥及配置文件,或获取指定配置的私钥文件对应的公钥。 + +Params: + 没有额外参数 +``` + +### 计算 Node ID + +子命令 `idminer` 用于计算指定配置文件(对应的私钥)的 Node ID(Node ID 的相关知识请参考[链接](terms#Node-ID))。示例: + +```bash +cql idminer ``` 输出: - INFO[0000] Bitcoin balance is: 0 - +```bash +INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 +Enter master key(press Enter for default: ""): + +INFO[0008] init config success path=/home/levente/.cql/config.yaml +INFO[0008] use public key in config file: /home/levente/.cql/config.yaml +INFO[0008] cpu: 8 +INFO[0008] position: 3, shift: 0x20, i: 7 +INFO[0008] position: 0, shift: 0x0, i: 0 +INFO[0008] position: 3, shift: 0x0, i: 6 +INFO[0008] position: 1, shift: 0x0, i: 2 +INFO[0008] position: 2, shift: 0x0, i: 4 +INFO[0008] position: 1, shift: 0x20, i: 3 +INFO[0008] position: 2, shift: 0x20, i: 5 +INFO[0008] position: 0, shift: 0x20, i: 1 +nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} +node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e +``` + +> 这一功能实际使用过程中暂时不会用到 + +### 子命令 `idminer` 完整参数 -## 转账 +```bash +usage: cql idminer [-config file] [-difficulty number] [-loop false] + +为指定配置的私钥文件计算新的 Node ID。 + +Params: + -difficulty int + 生成 Node ID 的难度要求,默认值为 24 + -loop + 循环计算以取得更高难度的 Node ID +``` + +## 钱包管理 + +### 查看钱包地址 -转账操作使用 `cql transfer` 并以 `json` 格式的转账信息为参数。 +在配置好账号以后,可以通过 `wallet` 子命令来获取账号的钱包地址: + +```bash +cql wallet +``` + +输出: + +```bash +Enter master key(press Enter for default: ""): + +wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 +``` + +这里可以看到我们用于测试的账号私钥文件对应的钱包地址是 `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`。 + +### 查看钱包余额 + +获得钱包地址之后,就可以使用 `wallet` 子命令来查看你的钱包余额了。目前 CovenantSQL 支持的代币类型为以下 5 种: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +其中 `Particle` 和 `Wave` 为 CovenantSQL 默认使用的代币,查看默认代币余额的命令为: + +```bash +cql wallet -balance all +``` + +输出: + +```bash +INFO[0000] Particle balance is: 10000000000000000000 +INFO[0000] Wave balance is: 10000000000000000000 +``` + +也可以单独指定代币类型,如查看 `Bitcoin` 余额: + +```bash +cql wallet -balance Bitcoin +``` + +输出: + +```bash +INFO[0000] Bitcoin balance is: 0 +``` + +### 向其他账号转账 + +从 [TestNet](quickstart) 获得代币或 [Docker 一键部署](deployment)的网络获得代币后,可以使用 `transfer` 命令来向其他账号转账。转账操作使用 `json` 格式的转账信息作为参数,例如: ```json { - "addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 - "amount":"1000000 Particle" // 转账金额并带上单位 + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 + "amount": "1000000 Particle" // 转账金额并带上单位 } ``` 其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 -转账 Particle: +把以上参数传给 `transfer` 子命令来进行转账: ```bash -cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Particle"}' +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` + +注意,以上输出信息只说明交易请求已经成功发送至 CovenantSQL 网络,需要等待 BP 节点执行并确认交易后才能实际生效。交易能否成功、何时成功可以通过执行 `cql wallet -balance ` 来确定,也可以在执行命令时添加 `-wait-tx-confirm` 参数来让 `cql` 命令查询到执行结果之后再退出。 -转账 Wave: +### 子命令 `wallet` 完整参数 ```bash -cql transfer -config conf/config.yaml '{"addr":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount":"1000000 Wave"}' +usage: cql wallet [-config file] [-balance token_type] + +查看账号钱包地址和代币余额。 +示例: + cql wallet + cql wallet -balance Particle + cql wallet -balance all + +Params: + -balance string + 获取当前账号中指定代币类型的余额 ``` - INFO[0000] succeed in sending transaction to CovenantSQL - +### 子命令 `transfer` 完整参数 -查看余额: +```bash +usage: cql transfer [-config file] [-wait-tx-confirm] meta_json + +向目标账号地址进行转账。输入参数为 JSON 格式的转账交易数据。 +示例: + cql transfer '{"addr": "your_account_addr", "amount": "100 Particle"}' + +由于 CovenantSQL 是区块链上的数据库,在交易生效之前你可能需要等待执行确认。 +示例: + cql transfer -wait-tx-confirm '{"addr": "your_account_addr", "amount": "100 Particle"}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +## 数据库管理 + +### 创建数据库 + +创建数据库与 `transfer` 子命令类似使用 `json` 格式的输入参数,创建由一个节点组成的数据库: ```bash -cql wallet -balance all -config conf/config.yaml +cql create '{"node": 1}' ``` 输出: - INFO[0000] Particle balance is: 9999999999999000000 - INFO[0000] Wave balance is: 9999999999999000000 - +```bash +Enter master key(press Enter for default: ""): + +covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` -注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易能否成功、何时成功需要通过 `cql wallet -balance ` 确定。 +注意这里生成的 `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 即为数据库的连接字符串(dsn),其中 `covenantsql` 为数据库协议字段,一般也可以缩写为 `cql`;`//` 后的十六进制串为数据库地址,可以在 `transfer` 子命令中作为收款地址使用。 -## 数据库权限管理 +子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 + +关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 + +### ~~删除数据库~~ + +~~未实现。~~ + +### 数据库权限管理 #### 访问权限 @@ -117,56 +305,60 @@ CovenantSQL 数据库有三类库级别权限: - `Read` - `Void` -其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。若 `Admin` 需要赋予他人权限请使用 `cql grant` 并以 `json` 格式的权限信息为参数: +其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。 + +假设我们用默认账号创建好了数据库 `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5`,在目录 `account2` 下创建好新账号配置,账号地址为 `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`,现在用默认账号给新账号授权已经创建好的数据库的访问权限,同样使用 `json` 格式的授权信息为参数: ```json { - "chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 - "user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 - "perm":"Write" // 权限内容 + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 + "perm": "Read,Write" // 权限内容,多个权限用英文逗号隔开 } ``` -增加写权限: +把以上参数传给 `grant` 子命令来增加读写权限: ```bash -cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user":"011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Write"}' +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` 吊销权限: ```bash -cql grant -config conf/config.yaml '{"chain":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","perm":"Void"}' +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' ``` 输出: - INFO[0000] succeed in sending transaction to CovenantSQL - +```bash +INFO[0000] succeed in sending transaction to CovenantSQL +``` -注意,`succeed in sending transaction to CovenantSQL` 只说明交易已成功发送至主网,交易成功与否请通过查询数据库确认。 +子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 -为数据库添加新的账户权限后账户需补充押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 +由于目前每个数据库实例分别为每个用户独立计费,所以为数据库添加新的账户权限后,需要以新账户身份向该数据库转押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 使用新账户给数据库充值: ```bash -cql transfer -config new_user_config/config.yaml '{"addr":"4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount":"90000000 Particle"}' +cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' ``` #### SQL 白名单 -CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除货更新操作。 +CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除或更新操作。 增加白名单: -```shell -cql -config conf/config.yaml -update-perm ' +```bash +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", @@ -175,7 +367,7 @@ cql -config conf/config.yaml -update-perm ' "SELECT COUNT(1) FROM a", "SELECT * FROM a WHERE id = ? LIMIT 1" ], - "role": "Read" + "role": "Read,Write" } } ' @@ -183,29 +375,265 @@ cql -config conf/config.yaml -update-perm ' *白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* -设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a`的 总数据量。 +设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a` 的总数据量。 去掉白名单限制: -```shell -cql -config conf/config.yaml -update-perm ' +```bash +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": { "patterns": nil, - "role": "Read" + "role": "Read,Write" } } ' # or -cql -config conf/config.yaml -update-perm ' +cql grant ' { "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", - "perm": "Read" + "perm": "Read,Write" } ' ``` -将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 \ No newline at end of file +将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 + +### 子命令 `create` 完整参数 + +```bash +usage: cql create [-config file] [-wait-tx-confirm] db_meta_json + +为当前账号创建数据库实例,输入参数为 JSON 格式的创建交易数据,其中节点数 node 为必带字段。 +示例: + cql create '{"node": 2}' + +完整的 db_meta_json 字段解释如下: + targetminers []string // 目标节点的账号地址 + node int // 目标节点数 + space int // 需要的硬盘空间,0 为任意 + memory int // 需要的内存空间,0 为任意 + loadavgpercpu float // 需要的 CPU 资源占用,0 为任意 + encryptionkey string // 落盘加密密钥 + useeventualconsistency bool // 各个数据库节点之间是否使用最终一致性同步 + consistencylevel float // 一致性级别,通过 node*consistencylevel 得到强同步的节点数 + isolationlevel int // 单个节点上的隔离级别,默认级别为线性级别 + +由于 CovenantSQL 是区块链上的数据库,在真正访问数据库之前你可能需要等待创建请求的执行确认以及在数据库节点上的实际创建。 +示例: + cql create -wait-tx-confirm '{"node": 2}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +### 子命令 `drop` 完整参数 + +```bash +usage: cql drop [-config file] [-wait-tx-confirm] dsn/dbid + +通过数据库的连接字符串或账号地址来删除数据库。 +示例: + cql drop the_dsn_of_your_database + +由于 CovenantSQL 是区块链上的数据库,在删除操作生效之前你可能需要等待删除请求的执行确认以及在数据库节点上的实际执行。 +示例: + cql drop -wait-tx-confirm the_dsn_of_your_database + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +### 子命令 `grant` 完整参数 + +```bash +usage: cql grant [-config file] [-wait-tx-confirm] permission_meta_json + +为指定账号进行数据库权限授权。 +示例: + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + +由于 CovenantSQL 是区块链上的数据库,在授权操作生效之前你可能需要等待授权请求的执行确认以及在数据库节点上的实际更新。 +示例 + cql grant -wait-tx-confirm '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + +Params: + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` + +## 访问数据库 + +完成数据库的创建后,就可以使用 `console` 子命令来对数据库进行交互式的命令行访问了: + +```bash +cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +输出 + +```bash +Enter master key(press Enter for default: ""): + +INFO[0010] init config success path=/home/levente/.cql/config.yaml +INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" +Connected with driver covenantsql (develop-34ae741a-20190416184528) +Type "help" for help. + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +或者使用以授权的账号来连接: + +```bash +cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +输出 + +```bash +Enter master key(press Enter for default: ""): + +INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml +INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" +Connected with driver covenantsql (develop-34ae741a-20190416184528) +Type "help" for help. + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +交互式访问示例: + +```bash +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); +CREATE TABLE +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); +INSERT +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; +c1 +---- +1 +2 +3 +(3 rows) + +co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +``` + +### 子命令 `console` 完整参数 + +子命令 `console` 同时也支持在后台启动 `adapter` 和 `explorer` 服务,关于这些服务的相关说明请参考 [本地服务](#本地服务) 的相关章节。 + +```bash +usage: cql console [-config file] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] + +为 CovenantSQL 运行交互式的命令行访问。 +示例: + cql console -dsn the_dsn_of_your_database + +另外也可以通过 -command 参数来直接运行 SQL 查询语句或通过 -file 参数来从文件读取查询语句。 +在指定了这些参数的情况下 `console` 子命令将会直接执行命令后退出,而不会进入交互式的命令行模式。 +示例: + cql console -dsn the_dsn_of_your_database -command "create table test1(test2 int);" + +Params: + -adapter string + 指定数据库子链的 adapter 服务器的监听地址 + -command string + 执行单条 SQL 语句并退出 + -dsn string + 数据库连接字符串 + -explorer string + 指定数据库子链的 explorer 服务器监听地址 + -file string + 执行 SQL 脚本中的语句并退出 + -no-rc + 启动时不加载 .rc 初始脚本 + -out string + 指定输出文件 + -single-transaction + 在非交互模式下使用单个事务执行所有语句 + -variable value + 设置环境变量 +``` + +## 本地服务 + +### Explorer 完整参数 + +```bash +usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address + +为数据库子链运行 adapter 服务器。 +示例: + cql explorer 127.0.0.1:8546 + +Params: + -bg-log-level string + 后台服务日志级别 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +### Mirror 完整参数 + +```bash +usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address + +为数据库子链运行 mirror 服务器。 +示例: + cql mirror database_id 127.0.0.1:9389 + +Params: + -bg-log-level string + 后台服务日志级别 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +### Adapter 完整参数 + +```bash +usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address + +为数据库子链运行 adapter 服务器。 +示例: + cql adapter 127.0.0.1:7784 + +Params: + -bg-log-level string + 后台服务日志级别 + -mirror string + 指定镜像 adapter 服务器地址 + -tmp-path string + 后台服务使用的临时目录,默认使用系统的默认临时文件路径 +``` + +## 高级使用 + +### RPC 完整参数 + +```bash +usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request + +向目标服务器发送 RPC 请求。 +示例: + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + +Params: + -endpoint string + 目标 RPC 服务地址 + -name string + 目标 RPC 方法名 + -req string + RPC 请求数据,JSON 格式 + -wait-tx-confirm + 等待交易执行确认(或者出现任何错误)后再退出 +``` \ No newline at end of file From f24080352a8e6d3a437a27a74359c9835bd2ea4f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 10:44:38 +0800 Subject: [PATCH 157/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md index a58841e..a42f3c7 100644 --- a/website/translated_docs/zh-CN/cql.md +++ b/website/translated_docs/zh-CN/cql.md @@ -52,7 +52,8 @@ cql generate config ```bash Generating key pair... -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 Generated key pair. @@ -80,7 +81,7 @@ cql generate public 输出: ```bash -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): INFO[0011] init config success path=/home/levente/.cql/private.key INFO[0011] use public key in config file: /home/levente/.cql/config.yaml @@ -162,7 +163,7 @@ cql wallet 输出: ```bash -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 ``` @@ -563,7 +564,7 @@ Params: ## 本地服务 -### Explorer 完整参数 +### 子命令 `explorer` 完整参数 ```bash usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address @@ -579,7 +580,7 @@ Params: 后台服务使用的临时目录,默认使用系统的默认临时文件路径 ``` -### Mirror 完整参数 +### 子命令 `mirror` 完整参数 ```bash usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address @@ -595,7 +596,9 @@ Params: 后台服务使用的临时目录,默认使用系统的默认临时文件路径 ``` -### Adapter 完整参数 +### 子命令 `adapter` 完整参数 + +关于 `adapter` 服务的说明请参考 。 ```bash usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address @@ -615,7 +618,9 @@ Params: ## 高级使用 -### RPC 完整参数 +子命令 `rpc` 直接在 CovenantSQL 网络上进行 RPC 调用。 + +### 子命令 `rpc` 完整参数 ```bash usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request @@ -628,9 +633,9 @@ usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_en Params: -endpoint string - 目标 RPC 服务地址 + 目标 RPC Node ID -name string - 目标 RPC 方法名 + 目标 RPC 服务.方法名 -req string RPC 请求数据,JSON 格式 -wait-tx-confirm From 6fa1172aa2a1ae38ea5626ead31a5d554253cf18 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 10:44:48 +0800 Subject: [PATCH 158/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql.md | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md index 7fdc6ed..880c26d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -53,7 +53,8 @@ cql generate config ```bash Generating key pair... -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): + Private key file: ~/.cql/private.key Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 Generated key pair. @@ -81,7 +82,7 @@ cql generate public 输出: ```bash -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): INFO[0011] init config success path=/home/levente/.cql/private.key INFO[0011] use public key in config file: /home/levente/.cql/config.yaml @@ -163,7 +164,7 @@ cql wallet 输出: ```bash -Enter master key(press Enter for default: ""): +Enter master key(press Enter for default: ""): wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 ``` @@ -564,7 +565,7 @@ Params: ## 本地服务 -### Explorer 完整参数 +### 子命令 `explorer` 完整参数 ```bash usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address @@ -580,7 +581,7 @@ Params: 后台服务使用的临时目录,默认使用系统的默认临时文件路径 ``` -### Mirror 完整参数 +### 子命令 `mirror` 完整参数 ```bash usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address @@ -596,7 +597,9 @@ Params: 后台服务使用的临时目录,默认使用系统的默认临时文件路径 ``` -### Adapter 完整参数 +### 子命令 `adapter` 完整参数 + +关于 `adapter` 服务的说明请参考 。 ```bash usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address @@ -616,7 +619,9 @@ Params: ## 高级使用 -### RPC 完整参数 +子命令 `rpc` 直接在 CovenantSQL 网络上进行 RPC 调用。 + +### 子命令 `rpc` 完整参数 ```bash usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request @@ -629,9 +634,9 @@ usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_en Params: -endpoint string - 目标 RPC 服务地址 + 目标 RPC Node ID -name string - 目标 RPC 方法名 + 目标 RPC 服务.方法名 -req string RPC 请求数据,JSON 格式 -wait-tx-confirm From 9d15dfd720ba4f7b31231d18e272c80d4d319978 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:07 +0800 Subject: [PATCH 159/421] New translations adpater.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/adpater.md | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md index 85992aa..5bae4e4 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/adpater.md +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -3,19 +3,19 @@ id: version-0.5.0-adapter title: '📦 CovenantSQL Adapter SDK' original_id: adapter --- -# 通过 Adapter 使用 CovenantSQL +# Use Adapter to access CovenantSQL -## 简介 +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP Rest requests. -`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 +## How to use -## 安装和使用 +First, [Install docker](https://docs.docker.com/install/). -首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) +Secondly, before using CovenantSQL, a proper configuration file and an asymmetric key-pair is required. If no configuration file is specified, CovenantSQL tries to load configuration from `~/.cql/config.yaml`. For configuration file and key-pair generation, please refer to [QuickStart#CreateAccount](./quickstart#CreateAccount) -### Docker 运行 Adapter +### Start adapter using docker -下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` +Following command will use config file `~/.cql/config.yaml` and key-pair `~/.cql/private.key` to start adapter service and serving at `0.0.0.0:11105`. ```bash export adapter_addr=0.0.0.0:11105 @@ -28,9 +28,11 @@ docker run -itd \ covenantsql/covenantsql:testnet 0.0.0.0:4661 ``` -### 创建数据库 +### Create database -使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 +Create new database using `cql create` command and provide database instance requirements. + +For example, create a single node database instance: ```shell docker run -it --rm \ @@ -40,14 +42,17 @@ docker run -it --rm \ create -config /app/config.yaml -wait-tx-confirm '{"node": 1}' ``` -命令会返回创建的数据库实例的连接串(DSN) +This command would produce a database connection string (DSN) similar to following example. ```shell covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -## 主流语言 Driver 的使用 +Use DSN to access CovenantSQL using various drivers. + +## Drivers -1. [Java](./driver_java) -2. [Python](./driver_python) -3. [NodeJS](./driver_js) \ No newline at end of file +1. [Golang](./driver_golang) +2. [Java](./driver_java) +3. [Python](./driver_python) +4. [NodeJS](./driver_js) \ No newline at end of file From 43093f452fc4f6285e55e4be6395bff26e95bb14 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:09 +0800 Subject: [PATCH 160/421] New translations driver_java.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_java.md | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index bb03333..c6dcf52 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -3,23 +3,21 @@ id: version-0.5.0-driver_java title: '📦 Java' original_id: driver_java --- -## 用 Java 使用 CovenantSQL +## Use Java to access CovenantSQL -### 简介 +`CovenantSQL` provides `Java SDK` to access database instance through [`Adapter`](./adapter) service. -`CovenantSQL` 提供了 `Java SDK`,可通过 `Adapter` 工具转换协议访问数据库实例。 +`Java SDK` is compatible with `JDBC4` specifications,and popular `ORM` like `MyBatis` is supported through JDBC interface. -`Java SDK` 遵守 `Java` 标准的 `JDBC4` 接口定义,能够使用常见的 `ORM` 例如 `MyBatis` 进行使用。 +### Compatibility -### 兼容性 +`Java SDK` requires `Java 1.7+`. -`Java SDK` 目前只兼容 `Java 1.7+` 的 `JDK` 版本。 +### Installation and quick start -### 安装和使用 +Before using `Java SDK`, an adapter tool deployment is required, please see [Deploy Adapter Service](./adapter). -使用 `Java SDK` 需要 [部署 Adapter 工具](./adapter)。 - -然后通过 `jdbc:covenantsql:///` URI,将其中的 `adapter_endpoint` 替换为 adapter 的地址,`database_id` 替换为数据库的 DSN 串访问数据库实例。 +Now you can use `jdbc:covenantsql:///` uri,replacing `adapter_endpoint` with adapter listen address,`database_id` with database id。 #### Maven @@ -62,8 +60,8 @@ dependencies { } ``` -### 示例 +### Examples -1. [JDBC示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) -2. [MyBatis示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) -3. [大型项目示例](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file +1. [JDBC Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +3. [SpringBoot + MyBatis Project Example](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From 2c5ea987e1d58b8b6196ae5383ef02ce294606b5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:10 +0800 Subject: [PATCH 161/421] New translations driver_python.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_python.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md index af9f079..d9a537c 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -3,27 +3,27 @@ id: version-0.5.0-driver_python title: '📦 Python' original_id: driver_python --- -## 用 Python 使用 CovenantSQL +## Use Python to access CovenantSQL -开发者可以通过 [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) 来使用 CovenantSQL。 +Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). -### 兼容性 +### Compatibility -`Python SDK` 目前只兼容 `python 3.4+` +`Python SDK` requires `python 3.4+`. -### 安装和使用 +### Installation and quick start -使用 `Python SDK` 需要 [部署 Adapter 工具](./adapter)。 +Before using `Python SDK`, an adapter deployment is required, please see [Deploy Adapter Service](./adapter). -使用 pip 安装 PyCovenantSQL +Install `PyCovenantSQL` using pip: ```shell $ python3 -m pip install PyCovenantSQL ``` -### 示例 +### Example -将 `adapter_host` 替换为 adapter 地址,`adapter_port` 替换为 adapter 的端口,adapter +Replace `adapter_host` with adapter listen host, `adapter_port` with adapter listen port, `dsn` with database dsn. ```python import pycovenantsql @@ -31,7 +31,7 @@ import pycovenantsql # Connect to the database connection = pycovenantsql.connect(host='', port=, - database='' + database='' ) try: From bf89dce6cf97b63d9735fed830dd25b31e64ccc0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:15 +0800 Subject: [PATCH 162/421] New translations driver_golang.md (Chinese Simplified) --- .../translated_docs/zh-CN/driver_golang.md | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_golang.md b/website/translated_docs/zh-CN/driver_golang.md index f3f2d45..c39b391 100644 --- a/website/translated_docs/zh-CN/driver_golang.md +++ b/website/translated_docs/zh-CN/driver_golang.md @@ -2,33 +2,29 @@ id: driver_golang title: '📦 Golang' --- -## 用 Golang 使用 CovenantSQL +## Use Golang to access CovenantSQL -### 简介 +`CovenantSQL` provides `Golang SDK` to access database using native rpc protocol. The `cql` tool is developed based on `Golang SDK`. -`CovenantSQL` 提供了 `Golang SDK` ,支持以 `Golang` App 以原生通讯协议的形式访问数据库实例,是当前性能最高的使用方法, `cql` 等工具也是基于 `Golang SDK` 进行开发的。 +`Golang SDK` is compatible with Golang `database/sql` driver standard, and popular `Golang ORM` is supported for advanced uses. -`Golang SDK` 遵守 `Golang` 标准的 `database/sql` 接口定义,能够使用常见的 `Golang ORM` 进行使用。 +### Compatibility -### 兼容性 +`Golang SDK` is compatible with Golang `1.10+`. -`Golang SDK` 目前只兼容 `1.10+` 的 Golang 版本。 +### Installation and quick start -### 安装和使用 - -`Golang SDK` 的 import 地址是 `github.com/CovenantSQL/CovenantSQL/client` - -可以执行 `go get` 命令进行安装 +Install it with: ```shell go get github.com/CovenantSQL/CovenantSQL/client ``` -### API 文档 +### API doc https://godoc.org/github.com/CovenantSQL/CovenantSQL/client -### 示例 +### Example ```go package main @@ -50,13 +46,13 @@ func main() { flag.StringVar(&password, "password", "", "master key password for covenantsql") flag.Parse() - // 使用节点配置文件初始化 Golang SDK + // Use config file to initialize Golang SDK err := client.Init(config, []byte(password)) if err != nil { log.Fatal(err) } - // 连接数据库实例 + // Connect to database instance db, err := sql.Open("covenantsql", dsn) if err != nil { log.Fatal(err) @@ -80,7 +76,7 @@ func main() { ); CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` - // 写入数据 + // Insert records _, err = db.Exec(Q) if err != nil { log.Fatal(err) @@ -118,7 +114,7 @@ func main() { ORDER BY Population DESC LIMIT 10;` - // 查询数据 + // Query records rows, err := db.Query(Q) if err != nil { log.Fatal(err) From 898b0b1dc4b4b681eecfde96d526956c9e8d6fc9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:17 +0800 Subject: [PATCH 163/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_js.md | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_js.md b/website/translated_docs/zh-CN/driver_js.md index c173d7a..a1f40e2 100644 --- a/website/translated_docs/zh-CN/driver_js.md +++ b/website/translated_docs/zh-CN/driver_js.md @@ -2,13 +2,13 @@ id: driver_js title: '📦 Javascript' --- -## 用 NodeJS 使用 CovenantSQL +## Use Javascript to access CovenantSQL -NodeJS 开发者可以通过 [node-covenantsql](https://github.com/CovenantSQL/node-covenantsql) 来与 CovenantSQL Adapter 进行交互。 +Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). -#### 下载安装 +#### Installation -可以直接通过 `npm` 或者 `yarn` 来安装 `node-covenantsql` +Install `node-covenantsql` using package manager `npm` or `yarn`: ```bash npm install --save node-covenantsql @@ -20,23 +20,20 @@ or yarn add node-covenantsql ``` -#### 使用 +#### Quick start -使用前需要 [部署 Adapter 工具](./adapter) +First, [Deploy Adapter Service](./adapter). -在运行本地 Adapter 之后,将 Adapter 的 endpoint 填入 `node-covenantsql` 的 config 之中: +Configure `node-covenantsql`, replace `adapter_listen_address` with adapter listen address, replace `database_id` with created database id: ```javascript const config = { - endpoint: 'localhost:11105', // local testnet endpoint without https - database: `${DSN}`, // your DB id created by `cql` tools - bypassPem: true // bypass https config + endpoint: '', // local testnet endpoint without https + database: 'database_id', // your DB id created by `cql` tools } ``` -这里 `bypassPem` 为 `true` 表示应用中所有对链上数据库的操作都会经过本地的 Adapter 进行代理,我们默认本地环境是可控,安全的,无需用 HTTPS 来保证这段连接的信道安全,少了证书的繁琐认证,所以成为 `bypassPem`。 - -接着连通之后则可进行链上数据库的增删改查: +After successfully connected to adapter, any CRUD operation is available using typical database operations: ```typescript const cql from 'node-covenantsql' From fd63cdfcaefb9476e8235d7e5f39b65468f5372e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:23 +0800 Subject: [PATCH 164/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 33 ++++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index dd7ceb8..45bb887 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -2,19 +2,19 @@ id: adapter title: '📦 CovenantSQL Adapter SDK' --- -# 通过 Adapter 使用 CovenantSQL +# Use Adapter to access CovenantSQL -## 简介 +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP Rest requests. -`CovenantSQL` 提供了 HTTP/HTTPS Adapter,类似于云数据库, 开发者可以直接用 HTTP 的形式使用 CovenantSQL。 +## How to use -## 安装和使用 +First, [Install docker](https://docs.docker.com/install/). -首先,需要确认我们有一个可用的配置和公私钥对,通常我们默认的配置和公私钥对的存储位置为 `~/.cql/` 目录。生成或获取请参考 [QuickStart#创建账号](./quickstart#创建账号) +Secondly, before using CovenantSQL, a proper configuration file and an asymmetric key-pair is required. If no configuration file is specified, CovenantSQL tries to load configuration from `~/.cql/config.yaml`. For configuration file and key-pair generation, please refer to [QuickStart#CreateAccount](./quickstart#CreateAccount) -### Docker 运行 Adapter +### Start adapter using docker -下面的命令将使用`~/.cql/config.yaml` 和 `~/.cql/private.key` 启动 Adapter,并把端口映射在 `0.0.0.0:11105` +Following command will use config file `~/.cql/config.yaml` and key-pair `~/.cql/private.key` to start adapter service and serving at `0.0.0.0:11105`. ```bash export adapter_addr=0.0.0.0:11105 @@ -27,9 +27,11 @@ docker run -itd \ covenantsql/covenantsql:testnet 0.0.0.0:4661 ``` -### 创建数据库 +### Create database -使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 +Create new database using `cql create` command and provide database instance requirements. + +For example, create a single node database instance: ```shell docker run -it --rm \ @@ -39,14 +41,17 @@ docker run -it --rm \ create -config /app/config.yaml -wait-tx-confirm '{"node": 1}' ``` -命令会返回创建的数据库实例的连接串(DSN) +This command would produce a database connection string (DSN) similar to following example. ```shell covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -## 主流语言 Driver 的使用 +Use DSN to access CovenantSQL using various drivers. + +## Drivers -1. [Java](./driver_java) -2. [Python](./driver_python) -3. [NodeJS](./driver_js) \ No newline at end of file +1. [Golang](./driver_golang) +2. [Java](./driver_java) +3. [Python](./driver_python) +4. [NodeJS](./driver_js) \ No newline at end of file From ed6f49c967284ad4e4470347da1b91dca0cefaac Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:24 +0800 Subject: [PATCH 165/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 32 +++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 6e185d2..05e5f39 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -2,23 +2,21 @@ id: driver_java title: '📦 Java' --- -## 用 Java 使用 CovenantSQL +## Use Java to access CovenantSQL -### 简介 +`CovenantSQL` provides `Java SDK` to access database instance through [`Adapter`](./adapter) service. -`CovenantSQL` 提供了 `Java SDK`,可通过 `Adapter` 工具转换协议访问数据库实例。 +`Java SDK` is compatible with `JDBC4` specifications,and popular `ORM` like `MyBatis` is supported through JDBC interface. -`Java SDK` 遵守 `Java` 标准的 `JDBC4` 接口定义,能够使用常见的 `ORM` 例如 `MyBatis` 进行使用。 +### Compatibility -### 兼容性 +`Java SDK` requires `Java 1.7+`. -`Java SDK` 目前只兼容 `Java 1.7+` 的 `JDK` 版本。 +### Installation and quick start -### 安装和使用 +Before using `Java SDK`, an adapter tool deployment is required, please see [Deploy Adapter Service](./adapter). -使用 `Java SDK` 需要 [部署 Adapter 工具](./adapter)。 - -然后通过 `jdbc:covenantsql:///` URI,将其中的 `adapter_endpoint` 替换为 adapter 的地址,`database_id` 替换为数据库的 DSN 串访问数据库实例。 +Now you can use `jdbc:covenantsql:///` uri,replacing `adapter_endpoint` with adapter listen address,`database_id` with database id。 #### Maven @@ -26,7 +24,7 @@ title: '📦 Java' mvn-repo - https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo + https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo true @@ -41,7 +39,7 @@ title: '📦 Java' io.covenantsql - covenantsql-java + covenantsql-java-connector 1.0-SNAPSHOT @@ -52,7 +50,7 @@ title: '📦 Java' ```gradle repositories { maven { - url 'https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo' + url 'https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo' } } @@ -61,8 +59,8 @@ dependencies { } ``` -### 示例 +### Examples -1. [JDBC示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) -2. [MyBatis示例](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) -3. [大型项目示例](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file +1. [JDBC Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +3. [SpringBoot + MyBatis Project Example](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From c9385fdb39da7d303c587a16a0d328ee0519114e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 11:57:25 +0800 Subject: [PATCH 166/421] New translations driver_python.md (Chinese Simplified) --- .../translated_docs/zh-CN/driver_python.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md index b86897a..e1192ed 100644 --- a/website/translated_docs/zh-CN/driver_python.md +++ b/website/translated_docs/zh-CN/driver_python.md @@ -2,27 +2,27 @@ id: driver_python title: '📦 Python' --- -## 用 Python 使用 CovenantSQL +## Use Python to access CovenantSQL -开发者可以通过 [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) 来使用 CovenantSQL。 +Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). -### 兼容性 +### Compatibility -`Python SDK` 目前只兼容 `python 3.4+` +`Python SDK` requires `python 3.4+`. -### 安装和使用 +### Installation and quick start -使用 `Python SDK` 需要 [部署 Adapter 工具](./adapter)。 +Before using `Python SDK`, an adapter deployment is required, please see [Deploy Adapter Service](./adapter). -使用 pip 安装 PyCovenantSQL +Install `PyCovenantSQL` using pip: ```shell $ python3 -m pip install PyCovenantSQL ``` -### 示例 +### Example -将 `adapter_host` 替换为 adapter 地址,`adapter_port` 替换为 adapter 的端口,adapter +Replace `adapter_host` with adapter listen host, `adapter_port` with adapter listen port, `dsn` with database dsn. ```python import pycovenantsql @@ -30,7 +30,7 @@ import pycovenantsql # Connect to the database connection = pycovenantsql.connect(host='', port=, - database='' + database='' ) try: From 88eabc67cda22674b6ed621a87869f1177d89d2f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 12:09:54 +0800 Subject: [PATCH 167/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/adpater.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md index 5bae4e4..24dbf68 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/adpater.md +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-adapter -title: '📦 CovenantSQL Adapter SDK' +title: '📦 Adapter SDK' original_id: adapter --- # Use Adapter to access CovenantSQL From a480ba23b2487cefc76c29061c39cfb2a84dee84 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 12:09:56 +0800 Subject: [PATCH 168/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_java.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index c6dcf52..894d538 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -25,7 +25,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo + https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo true @@ -40,7 +40,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl io.covenantsql - covenantsql-java + covenantsql-java-connector 1.0-SNAPSHOT @@ -51,7 +51,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://rawcdn.githack.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector/mvn-repo' + url 'https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo' } } From 23b95c74d65502b17a391d779e9d1d44a6d85804 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 12:09:57 +0800 Subject: [PATCH 169/421] New translations driver_golang.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_golang.md | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/driver_golang.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md new file mode 100644 index 0000000..13f9632 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md @@ -0,0 +1,169 @@ +--- +id: version-0.5.0-driver_golang +title: '📦 Golang' +original_id: driver_golang +--- +## Use Golang to access CovenantSQL + +`CovenantSQL` provides `Golang SDK` to access database using native rpc protocol. The `cql` tool is developed based on `Golang SDK`. + +`Golang SDK` is compatible with Golang `database/sql` driver standard, and popular `Golang ORM` is supported for advanced uses. + +### Compatibility + +`Golang SDK` is compatible with Golang `1.10+`. + +### Installation and quick start + +Install it with: + +```shell +go get github.com/CovenantSQL/CovenantSQL/client +``` + +### API doc + +https://godoc.org/github.com/CovenantSQL/CovenantSQL/client + +### Example + +```go +package main + +import ( + "database/sql" + "flag" + + "github.com/CovenantSQL/CovenantSQL/client" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + log.SetLevel(log.DebugLevel) + var config, password, dsn string + + flag.StringVar(&config, "config", "./conf/config.yaml", "config file path") + flag.StringVar(&dsn, "dsn", "", "database url") + flag.StringVar(&password, "password", "", "master key password for covenantsql") + flag.Parse() + + // Use config file to initialize Golang SDK + err := client.Init(config, []byte(password)) + if err != nil { + log.Fatal(err) + } + + // Connect to database instance + db, err := sql.Open("covenantsql", dsn) + if err != nil { + log.Fatal(err) + } + + Q := `DROP TABLE IF EXISTS cityPop; + CREATE TABLE cityPop ( + ID INT, + Name VARCHAR, + CountryCode VARCHAR, + District VARCHAR, + Population INT + ); + CREATE INDEX cityCountryCodeIndex ON cityPop ( CountryCode ); + + DROP TABLE IF EXISTS countryGDP; + CREATE TABLE countryGDP ( + ID integer PRIMARY KEY, + CountryCode string NOT NULL, + GDP integer + ); + CREATE INDEX countryCountryCodeIndex ON countryGDP ( CountryCode );` + + // Insert records + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `INSERT INTO countryGDP VALUES + (0, "ZWE", 99999),(1, "CHN", 3000000000000), + (2, "PSE", 321312313),(3, "JPN", 300000000); + INSERT INTO cityPop VALUES (707,'Shenzhen','CHN','Guangzhou',99442); + INSERT INTO cityPop VALUES (1074,'Shenzhen','CHN','Guangzhou',353632); + INSERT INTO cityPop VALUES (1591,'Toyama','JPN','Toyama',325790); + INSERT INTO cityPop VALUES (1649,'Takaoka','JPN','Toyama',174380); + INSERT INTO cityPop VALUES (1762,'Takasago','JPN','Hyogo',97632); + INSERT INTO cityPop VALUES (1763,'Fujimi','JPN','Saitama',96972); + INSERT INTO cityPop VALUES (1764,'Urasoe','JPN','Okinawa',96002); + INSERT INTO cityPop VALUES (1765,'Yonezawa','JPN','Yamagata',95592); + INSERT INTO cityPop VALUES (1766,'Konan','JPN','Aichi',95521); + INSERT INTO cityPop VALUES (1767,'Yamatokoriyama','JPN','Nara',95165); + INSERT INTO cityPop VALUES (1768,'Maizuru','JPN','Kyoto',94784); + INSERT INTO cityPop VALUES (1769,'Onomichi','JPN','Hiroshima',93756); + INSERT INTO cityPop VALUES (1770,'Higashimatsuyama','JPN','Saitama',93342); + INSERT INTO cityPop VALUES (2707,'Xai-Xai','MOZ','Gaza',99442); + INSERT INTO cityPop VALUES (4074,'Gaza','PSE','Gaza',353632); + INSERT INTO cityPop VALUES (4077,'Jabaliya','PSE','North Gaza',113901);` + _, err = db.Exec(Q) + if err != nil { + log.Warn(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT * FROM cityPop + WHERE District IN ("Shenzhen", "Balkh", "Gaza", "North Gaza") + GROUP BY cityPop.CountryCode + ORDER BY Population DESC + LIMIT 10;` + + // Query records + rows, err := db.Query(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + log.Println("ID Name CountryCode District Population") + var ID, GDP, Population int + var Name, CountryCode, District string + var GDPPerson float64 + + for rows.Next() { + err = rows.Scan(&ID, &Name, &CountryCode, &District, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %s %d", ID, Name, CountryCode, District, Population) + } + Q = `UPDATE countryGDP SET GDP = 1234567 WHERE CountryCode LIKE "CHN"; + UPDATE cityPop SET Population = 123456 WHERE CountryCode LIKE "CHN"; + REPLACE INTO countryGDP (ID, CountryCode, GDP) VALUES (77, "AFG", 11111111);` + _, err = db.Exec(Q) + if err != nil { + log.Fatal(err) + } + log.Printf("\nExec:\n %s\n", Q) + + Q = `SELECT cityPop.ID, cityPop.CountryCode, cityPop.District, + countryGDP.GDP / cityPop.Population, countryGDP.GDP, cityPop.Population + FROM cityPop + LEFT JOIN countryGDP + ON countryGDP.CountryCode = cityPop.CountryCode + WHERE District IN ( "Shenzhen", "Balkh", "North Gaza", "Toyama", "Yonezawa") AND countryGDP.GDP > 0 + GROUP BY cityPop.CountryCode + ORDER BY countryGDP.GDP / cityPop.Population DESC + LIMIT 10;` + rows, err = db.Query(Q) + log.Printf("\nExec:\n %s\n", Q) + + log.Println("ID CountryCode District GDPPerson GDP Population") + for rows.Next() { + err = rows.Scan(&ID, &CountryCode, &District, &GDPPerson, &GDP, &Population) + if err != nil { + log.Fatal(err) + } + + log.Printf("%d %s %s %f %d %d", + ID, CountryCode, District, GDPPerson, GDP, Population) + } +} +``` \ No newline at end of file From 78c381cb68ceffbdb68736b8055453f105b16002 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 12:10:09 +0800 Subject: [PATCH 170/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index 45bb887..a6546f0 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -1,6 +1,6 @@ --- id: adapter -title: '📦 CovenantSQL Adapter SDK' +title: '📦 Adapter SDK' --- # Use Adapter to access CovenantSQL From 4372832c3ae98fe60b62f6bc78d1224889416eeb Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 12:10:12 +0800 Subject: [PATCH 171/421] New translations driver_js.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/driver_js.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/driver_js.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_js.md b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md new file mode 100644 index 0000000..4012c58 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md @@ -0,0 +1,65 @@ +--- +id: version-0.5.0-driver_js +title: '📦 Javascript' +original_id: driver_js +--- +## Use Javascript to access CovenantSQL + +Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). + +#### Installation + +Install `node-covenantsql` using package manager `npm` or `yarn`: + +```bash +npm install --save node-covenantsql +``` + +or + +```bash +yarn add node-covenantsql +``` + +#### Quick start + +First, [Deploy Adapter Service](./adapter). + +Configure `node-covenantsql`, replace `adapter_listen_address` with adapter listen address, replace `database_id` with created database id: + +```javascript +const config = { + endpoint: '', // local testnet endpoint without https + database: 'database_id', // your DB id created by `cql` tools +} +``` + +After successfully connected to adapter, any CRUD operation is available using typical database operations: + +```typescript +const cql from 'node-covenantsql' + +const config = {...} // see above + +cql.createConnection(config).then(async (connection: any) => { + // read + const data1 = await connection.query("select ? + ?", [2.1, 3.2]); + console.log(data1); + + // write + const createTableSQL = ` + CREATE TABLE IF NOT EXISTS contacts (\ + contact_id INTEGER PRIMARY KEY, + first_name TEXT NOT NULL, + last_name TEXT NOT NULL, + email text NOT NULL UNIQUE, + phone text NOT NULL UNIQUE + ); + ` + const status1 = await connection.exec(createTableSQL) + console.log(`exec1 status:`, status1); + + const data2 = await connection.query("show tables;"); + console.log(data2); +}).catch((e: any) => console.log(e)) +``` \ No newline at end of file From 6913a8c3ef027c65b25a53f12422c6bf5cc02b91 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 14:16:38 +0800 Subject: [PATCH 172/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 137 ++++++++++++-------- 1 file changed, 86 insertions(+), 51 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index c2cd203..195dcad 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -4,24 +4,58 @@ title: '🌏 TestNet 快速开始' --- ## CovenantSQL 工具包 -### 工具包简介 +### 工具包安装 -请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 +请根据您使用的操作系统平台选择安装方式: -例如,您使用的是: +- MacOS 平台 + + - 🍺 Homebrew 用户可以直接在命令行: + +```bash + brew tap CovenantSQL/cql && brew install cql + ``` + + - 非 Homebrew,可以执行: + + - ```bash + curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + sudo tar xzv -C /usr/local/bin/ --strip-components=1 + ``` + +- Linux 平台请可以执行: + + - ```bash + curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + sudo tar xzv -C /usr/local/bin/ --strip-components=1 + ``` + +安装完成后可以执行下面的命令,查看是否安装成功 + +```bash +cql version +``` + +如果对于 MacOS 或者 Linux 平台有任何错误,可以执行如下命令进行修复: + +```bash +sudo chmod a+x /usr/local/bin/cql* # Fix Permission +sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH +``` -- MacOS 平台请下载:[**CovenantSQL-v0.5.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.osx-amd64.tar.gz) -- Linux 平台请下载:[**CovenantSQL-v0.5.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.linux-amd64.tar.gz) -- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) +如果问题依旧存在请在我们的 GitHub 页面[提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 -解压之后,你将得到以下命令行工具,包括:`cql`、`cql-minerd` 等, 请将此文件移动到 `PATH` 目录。 +### 工具包介绍 | 工具名 | 介绍 | | ---------- | ---------------------------------------------------------------- | | cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | +| cql-fuse | CovenantSQL 的 FUSE 客户端,可以把 CovenantSQL 数据库 mount 成文件系统 | | cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | | cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | +> Windows 平台我们稍后发布,有需求请在 GitHub [提 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 + ### 测试网快速接入 目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 @@ -29,34 +63,33 @@ title: '🌏 TestNet 快速开始' 测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: ```bash -mkdir conf -wget https://git.io/fhFZe -O conf/config.yaml -wget https://git.io/fhFZv -O conf/private.key -chmod 600 conf/private.key +mkdir -p ~/.cql/testnet-conf +curl -L https://git.io/fhFZe --output ~/.cql/testnet-conf/config.yaml +curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key +chmod 600 ~/.cql/testnet-conf/private.key ``` **测试网注**: > 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 > -> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 - -## 创建并访问 CovenantSQL 数据库 +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持 `create 3` 创建 3 个节点组成的数据库。 -### 创建数据库 +## 创建数据库 -```shell -cql create -config conf/config.yaml '{"node":1}' +```bash +cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ +-wait-tx-confirm '{"node":1}' ``` -在命令行提示中输入master key的密码,之后控制台会输出: +命令执行耗时较长,大约 30s 之后控制台会输出: covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 -这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 -> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> 命令执行耗时较长,大致过程为: > > 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 > 2. 数据库创建请求在 其它出块节点 进行验证和确认 @@ -64,52 +97,54 @@ cql create -config conf/config.yaml '{"node":1}' > 4. SQLChian 组建 Kayak 数据库集群 > 5. 所有 Miner 准备就绪等待请求 -### 访问数据库 +## 访问数据库 ```shell -cql console -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ +-dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` -在控制台中根据提示输入master key的密码。连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 - -### 数据库 SDK - -- [Golang 开发指引](./development) +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 ## SQLChain 区块浏览器 CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 -> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 +> 测试网的`区块浏览器`目前是开放权限的,使用 TestNet 的公共 Key 创建并且知道数据库 ID 的人都能看到您的数据 -查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 。你可以看到使用 TestNet 的 Key 创建的所有数据的信息: -## 创建账号 +![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) -我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): +> **如果想要创建自己的私有数据库,需要从头开始创建一个新的公私钥对,请参考下面的章节。** -```shell -cql generate config +## 创建新账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,可以加上 `-no-password` 留空): + +```bash +cql generate -no-password config ``` 输出: + INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 + "/home/work/.cql" already exists. + Do you want to delete it? (y or n, press Enter for default n): + y Generating key pair... - Enter master key(press Enter for default: ""): - Private key file: ~/.cql/private.key - Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Private key file: /home/work/.cql/private.key + Public key's hex: 024123d10696cf54fbf2b1e2b507ec4d1cbf2b4e87095774ad5fd6376cdae88e87 Generated key pair. Generating nonce... - INFO[0075] cpu: 4 - INFO[0075] position: 3, shift: 0x0, i: 3 - INFO[0075] position: 1, shift: 0x0, i: 1 - INFO[0075] position: 0, shift: 0x0, i: 0 - INFO[0075] position: 2, shift: 0x0, i: 2 - nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} - node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + INFO[0001] cpu: 2 + INFO[0001] position: 2, shift: 0x0, i: 1 + INFO[0001] position: 0, shift: 0x0, i: 0 + nonce: {{2556203225 0 0 0} 24 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad} + node id: 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad Generated nonce. Generating config file... - Generated nonce. + Generated config. 该命令会为你在~目录下创建一个 `.cql` 目录: @@ -119,28 +154,28 @@ cql generate config 再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): -```shell -cql wallet +```bash +cql wallet -no-password ``` 输出: ```toml -wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c ``` 你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): -```shell -cql wallet -balance all +```bash +cql wallet -no-password -balance all ``` 输出: - INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" - INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + Particle balance is: 100 + Wave balance is: 0 恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From eabf8f9c86fd4926a11588b1ba85e09e5a4d9521 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 14:16:46 +0800 Subject: [PATCH 173/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quickstart.md | 137 +++++++++++------- 1 file changed, 86 insertions(+), 51 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 1993893..81691da 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -5,24 +5,58 @@ original_id: quickstart --- ## CovenantSQL 工具包 -### 工具包简介 +### 工具包安装 -请根据您使用的操作系统平台选择 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。 +请根据您使用的操作系统平台选择安装方式: -例如,您使用的是: +- MacOS 平台 + + - 🍺 Homebrew 用户可以直接在命令行: + +```bash + brew tap CovenantSQL/cql && brew install cql + ``` + + - 非 Homebrew,可以执行: + + - ```bash + curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + sudo tar xzv -C /usr/local/bin/ --strip-components=1 + ``` + +- Linux 平台请可以执行: + + - ```bash + curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + sudo tar xzv -C /usr/local/bin/ --strip-components=1 + ``` + +安装完成后可以执行下面的命令,查看是否安装成功 + +```bash +cql version +``` + +如果对于 MacOS 或者 Linux 平台有任何错误,可以执行如下命令进行修复: + +```bash +sudo chmod a+x /usr/local/bin/cql* # Fix Permission +sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH +``` -- MacOS 平台请下载:[**CovenantSQL-v0.5.0.osx-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.osx-amd64.tar.gz) -- Linux 平台请下载:[**CovenantSQL-v0.5.0.linux-amd64.tar.gz**](https://github.com/CovenantSQL/CovenantSQL/releases/download/v0.5.0/CovenantSQL-v0.5.0.linux-amd64.tar.gz) -- Windows 平台我们稍后发布,有需求请戳这里:[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/CovenantSQL/CovenantSQL) +如果问题依旧存在请在我们的 GitHub 页面[提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 -解压之后,你将得到以下命令行工具,包括:`cql`、`cql-minerd` 等, 请将此文件移动到 `PATH` 目录。 +### 工具包介绍 | 工具名 | 介绍 | | ---------- | ---------------------------------------------------------------- | | cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | +| cql-fuse | CovenantSQL 的 FUSE 客户端,可以把 CovenantSQL 数据库 mount 成文件系统 | | cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | | cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | +> Windows 平台我们稍后发布,有需求请在 GitHub [提 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 + ### 测试网快速接入 目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 @@ -30,34 +64,33 @@ original_id: quickstart 测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: ```bash -mkdir conf -wget https://git.io/fhFZe -O conf/config.yaml -wget https://git.io/fhFZv -O conf/private.key -chmod 600 conf/private.key +mkdir -p ~/.cql/testnet-conf +curl -L https://git.io/fhFZe --output ~/.cql/testnet-conf/config.yaml +curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key +chmod 600 ~/.cql/testnet-conf/private.key ``` **测试网注**: > 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 > -> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持`create 3`创建 3 个节点组成的数据库。 - -## 创建并访问 CovenantSQL 数据库 +> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持 `create 3` 创建 3 个节点组成的数据库。 -### 创建数据库 +## 创建数据库 -```shell -cql create -config conf/config.yaml '{"node":1}' +```bash +cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ +-wait-tx-confirm '{"node":1}' ``` -在命令行提示中输入master key的密码,之后控制台会输出: +命令执行耗时较长,大约 30s 之后控制台会输出: covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 -这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链。 +这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 -> 我们需要等待大概 30s 的时间,等待数据库创建,大致过程为: +> 命令执行耗时较长,大致过程为: > > 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 > 2. 数据库创建请求在 其它出块节点 进行验证和确认 @@ -65,52 +98,54 @@ cql create -config conf/config.yaml '{"node":1}' > 4. SQLChian 组建 Kayak 数据库集群 > 5. 所有 Miner 准备就绪等待请求 -### 访问数据库 +## 访问数据库 ```shell -cql console -config conf/config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ +-dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` -在控制台中根据提示输入master key的密码。连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 - -### 数据库 SDK - -- [Golang 开发指引](./development) +连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 ## SQLChain 区块浏览器 CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 -> 测试网的`区块浏览器`目前是开放权限的,所以任何知道数据库 ID 的人都能看到您的数据 +> 测试网的`区块浏览器`目前是开放权限的,使用 TestNet 的公共 Key 创建并且知道数据库 ID 的人都能看到您的数据 -查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` +查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 。你可以看到使用 TestNet 的 Key 创建的所有数据的信息: -## 创建账号 +![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) -我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,测试期间建议直接回车留空): +> **如果想要创建自己的私有数据库,需要从头开始创建一个新的公私钥对,请参考下面的章节。** -```shell -cql generate config +## 创建新账号 + +我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,可以加上 `-no-password` 留空): + +```bash +cql generate -no-password config ``` 输出: + INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 + "/home/work/.cql" already exists. + Do you want to delete it? (y or n, press Enter for default n): + y Generating key pair... - Enter master key(press Enter for default: ""): - Private key file: ~/.cql/private.key - Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Private key file: /home/work/.cql/private.key + Public key's hex: 024123d10696cf54fbf2b1e2b507ec4d1cbf2b4e87095774ad5fd6376cdae88e87 Generated key pair. Generating nonce... - INFO[0075] cpu: 4 - INFO[0075] position: 3, shift: 0x0, i: 3 - INFO[0075] position: 1, shift: 0x0, i: 1 - INFO[0075] position: 0, shift: 0x0, i: 0 - INFO[0075] position: 2, shift: 0x0, i: 2 - nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} - node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + INFO[0001] cpu: 2 + INFO[0001] position: 2, shift: 0x0, i: 1 + INFO[0001] position: 0, shift: 0x0, i: 0 + nonce: {{2556203225 0 0 0} 24 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad} + node id: 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad Generated nonce. Generating config file... - Generated nonce. + Generated config. 该命令会为你在~目录下创建一个 `.cql` 目录: @@ -120,28 +155,28 @@ cql generate config 再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): -```shell -cql wallet +```bash +cql wallet -no-password ``` 输出: ```toml -wallet address: 4kcCg4niPjWURuFyT633V8TF9Xb9PvUR5Xbf6aTvGxFZkJFQaS9 +wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c ``` 你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): -```shell -cql wallet -balance all +```bash +cql wallet -no-password -balance all ``` 输出: - INFO[0000] stable coin balance is: 100 caller="main.go:246 main.main" - INFO[0000] covenant coin balance is: 0 caller="main.go:247 main.main" + Particle balance is: 100 + Wave balance is: 0 恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file From 715e37d5afa2e5e3190a5a617fd40b8b892ca3a8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 14:34:54 +0800 Subject: [PATCH 174/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 34 +++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 195dcad..0e70988 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -8,27 +8,29 @@ title: '🌏 TestNet 快速开始' 请根据您使用的操作系统平台选择安装方式: -- MacOS 平台 - - - 🍺 Homebrew 用户可以直接在命令行: +#### MacOS 平台 + +- 🍺 Homebrew 用户可以直接在命令行: ```bash - brew tap CovenantSQL/cql && brew install cql - ``` +brew tap CovenantSQL/cql && brew install cql +``` + +- 非 Homebrew,可以执行: - - 非 Homebrew,可以执行: +```bash +sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' +``` - - ```bash - curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ - sudo tar xzv -C /usr/local/bin/ --strip-components=1 - ``` +#### Linux 平台 -- Linux 平台请可以执行: +在命令行中执行: - - ```bash - curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ - sudo tar xzv -C /usr/local/bin/ --strip-components=1 - ``` +```bash +sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ +tar xzv -C /usr/local/bin/ --strip-components=1' +``` 安装完成后可以执行下面的命令,查看是否安装成功 @@ -43,7 +45,7 @@ sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -如果问题依旧存在请在我们的 GitHub 页面[提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +如果问题依旧存在请在我们的 GitHub 页面 [提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 ### 工具包介绍 From 046f70099988b9d61fcc10fb84ec928188acf563 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 17 Apr 2019 14:35:04 +0800 Subject: [PATCH 175/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quickstart.md | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 81691da..06eb95c 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -9,27 +9,29 @@ original_id: quickstart 请根据您使用的操作系统平台选择安装方式: -- MacOS 平台 - - - 🍺 Homebrew 用户可以直接在命令行: +#### MacOS 平台 + +- 🍺 Homebrew 用户可以直接在命令行: ```bash - brew tap CovenantSQL/cql && brew install cql - ``` +brew tap CovenantSQL/cql && brew install cql +``` + +- 非 Homebrew,可以执行: - - 非 Homebrew,可以执行: +```bash +sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' +``` - - ```bash - curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ - sudo tar xzv -C /usr/local/bin/ --strip-components=1 - ``` +#### Linux 平台 -- Linux 平台请可以执行: +在命令行中执行: - - ```bash - curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ - sudo tar xzv -C /usr/local/bin/ --strip-components=1 - ``` +```bash +sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ +tar xzv -C /usr/local/bin/ --strip-components=1' +``` 安装完成后可以执行下面的命令,查看是否安装成功 @@ -44,7 +46,7 @@ sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -如果问题依旧存在请在我们的 GitHub 页面[提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +如果问题依旧存在请在我们的 GitHub 页面 [提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 ### 工具包介绍 From dabae2b40530ff036314039a3ec5aafafec8c540 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:04 +0800 Subject: [PATCH 176/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md index a42f3c7..c73b324 100644 --- a/website/translated_docs/zh-CN/cql.md +++ b/website/translated_docs/zh-CN/cql.md @@ -1,6 +1,6 @@ --- id: cql -title: '🖥️ CQL 命令行工具集' +title: Client --- ## 简介 From 7ec0a48c6dafc1adbc17c3ce241ec1be06e6f996 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:05 +0800 Subject: [PATCH 177/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/qna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md index ad187f5..ea2a604 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/qna.md +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-qna -title: '🙋 常见问题解答' +title: Q&A original_id: qna --- ## TBD \ No newline at end of file From aad734c7d8e3b7534146832f2709a5d114ca505e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:07 +0800 Subject: [PATCH 178/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/deployment.md | 119 ++++++++++---------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/website/translated_docs/zh-CN/deployment.md b/website/translated_docs/zh-CN/deployment.md index 8b5b8c8..451e55a 100644 --- a/website/translated_docs/zh-CN/deployment.md +++ b/website/translated_docs/zh-CN/deployment.md @@ -1,123 +1,124 @@ --- id: deployment -title: '🐳 Docker 一键部署' +title: Docker Deploy --- -## 使用 CovenantSQL Docker 部署 +## Deploy with CovenantSQL Docker -### 安装 Docker +### Install Docker -需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL +You need to install docker and docker-compose on your machine to deploy CovenantSQL. Docker:https://docs.docker.com/install/ Docker-Compose:https://docs.docker.com/compose/install/ -### 下载项目 +### Download project ```bash git clone https://github.com/CovenantSQL/CovenantSQL cd CovenantSQL ``` -后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: ```bash export COVENANTSQL_ROOT=$PWD ``` -存为环境变量 +### Start Docker container -### 启动 Docker 容器 +There are now two ways to start the CovenantSQL container: -现在有两种方式启动 CovenantSQL 容器: +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image -1. 使用 Docker Hub 上的公共镜像 -2. 构建 CovenantSQL Docker 镜像 +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. -> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 +#### 1. Use a public image on Docker Hub -#### 1. 使用 Docker Hub 上的公共镜像 - -然后直接启动: +Then start directly: ```bash make start ``` -#### 2. 构建 CovenantSQL Docker 镜像 +#### 2. Build a CovenantSQL Docker image -执行以下的命令在本地运行 CovenantSQL +Run CovenantSQL locally by executing the following command ```bash -make docker # 从头编译新的镜像 +make docker # compile a new image from source files make start ``` -### 检查运行状态 +### Check running status -检查容器状态: +Check the container status: ```bash docker-compose ps ``` -确认所有组件都处于 `Up` 的状态 +Confirm that all components are in the `Up` state ```shell - Name Command State Ports ---------------------------------------------------------------------------------------------------------------------- -covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp -covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp, 0.0.0.0:12099->4665/tcp -covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp, 0.0.0.0:12100->4665/tcp -covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp, 0.0.0.0:12101->4665/tcp -covenantsql_fn_0 ./docker-entry.sh -wsapi :8546 Up 4661/tcp, 0.0.0.0:11110->8546/tcp -covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp, 0.0.0.0:12102->4665/tcp -covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp, 0.0.0.0:12103->4665/tcp -covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp, 0.0.0.0:12104->4665/tcp -covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer ./docker-entry.sh Up 4661/tcp, 0.0.0.0:11108->80/tcp + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp ``` -## 操作 CovenantSQL +## Operate CovenantSQL + +### Create a database -### 创建数据库 +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. -使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 +e.g.: creating a single-node database instance ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` -> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":2}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` -命令会返回创建的数据库实例的连接串 +The command will return the connection string of the created database instance ```shell -covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -### 访问数据库 +### Accessing the database -使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```shell -docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml -no-password -dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -会得到如下输出,并进入 `cql` 交互命令行模式 +After that, it will get the following output, and enter the `cql` interactive command line mode ```shell -Connected with driver covenantsql (develop-34ae741a-20190415135520) +Connected with driver covenantsql (develop) Type "help" for help. -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 +The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. ```sql CREATE TABLE test (test TEXT); @@ -126,36 +127,36 @@ INSERT INTO test VALUES("happy"); SELECT * FROM test; ``` -会得到如下输出 +After that, it will get the following output: ```shell -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> CREATE TABLE test (test TEXT); +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SHOW TABLES; +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; name ------ test (1 row) -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> INSERT INTO test VALUES("happy"); +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); INSERT -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SELECT * FROM test; +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; test ------- happy (1 row) -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line ### SQLChain Observer -镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. -(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) -#### 在浏览器使用 SQLChain Observer +#### Use SQLChain Observer in your browser -我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From 249d7bd438855e3ebb17e305a0b6e30c3f4537a9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:08 +0800 Subject: [PATCH 179/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment.md | 119 +++++++++--------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md index 0b2f381..5366a86 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -1,124 +1,125 @@ --- id: version-0.5.0-deployment -title: '🐳 Docker 一键部署' +title: Docker Deploy original_id: deployment --- -## 使用 CovenantSQL Docker 部署 +## Deploy with CovenantSQL Docker -### 安装 Docker +### Install Docker -需要在机器上安装 docker 和 docker-compose 来一键部署 CovenantSQL +You need to install docker and docker-compose on your machine to deploy CovenantSQL. Docker:https://docs.docker.com/install/ Docker-Compose:https://docs.docker.com/compose/install/ -### 下载项目 +### Download project ```bash git clone https://github.com/CovenantSQL/CovenantSQL cd CovenantSQL ``` -后续的所有命令,工作目录默认都是在 clone 的 CovenantSQL 源码目录中,可以执行 +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: ```bash export COVENANTSQL_ROOT=$PWD ``` -存为环境变量 +### Start Docker container -### 启动 Docker 容器 +There are now two ways to start the CovenantSQL container: -现在有两种方式启动 CovenantSQL 容器: +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image -1. 使用 Docker Hub 上的公共镜像 -2. 构建 CovenantSQL Docker 镜像 +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. -> 我们推荐普通用户使用第一种方式测试 CovenantSQL,第二种仅用于体验最新的开发中的特性。 +#### 1. Use a public image on Docker Hub -#### 1. 使用 Docker Hub 上的公共镜像 - -然后直接启动: +Then start directly: ```bash make start ``` -#### 2. 构建 CovenantSQL Docker 镜像 +#### 2. Build a CovenantSQL Docker image -执行以下的命令在本地运行 CovenantSQL +Run CovenantSQL locally by executing the following command ```bash -make docker # 从头编译新的镜像 +make docker # compile a new image from source files make start ``` -### 检查运行状态 +### Check running status -检查容器状态: +Check the container status: ```bash docker-compose ps ``` -确认所有组件都处于 `Up` 的状态 +Confirm that all components are in the `Up` state ```shell - Name Command State Ports ---------------------------------------------------------------------------------------------------------------------- -covenantsql_adapter ./docker-entry.sh Up 0.0.0.0:11105->4661/tcp -covenantsql_bp_0 ./docker-entry.sh Up 0.0.0.0:11099->4661/tcp, 0.0.0.0:12099->4665/tcp -covenantsql_bp_1 ./docker-entry.sh Up 0.0.0.0:11100->4661/tcp, 0.0.0.0:12100->4665/tcp -covenantsql_bp_2 ./docker-entry.sh Up 0.0.0.0:11101->4661/tcp, 0.0.0.0:12101->4665/tcp -covenantsql_fn_0 ./docker-entry.sh -wsapi :8546 Up 4661/tcp, 0.0.0.0:11110->8546/tcp -covenantsql_miner_0 ./docker-entry.sh Up 0.0.0.0:11102->4661/tcp, 0.0.0.0:12102->4665/tcp -covenantsql_miner_1 ./docker-entry.sh Up 0.0.0.0:11103->4661/tcp, 0.0.0.0:12103->4665/tcp -covenantsql_miner_2 ./docker-entry.sh Up 0.0.0.0:11104->4661/tcp, 0.0.0.0:12104->4665/tcp -covenantsql_mysql_adapter ./docker-entry.sh -listen ... Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer ./docker-entry.sh Up 4661/tcp, 0.0.0.0:11108->80/tcp + Name Command State Ports +------------------------------------------------------------------------------------------------------ +covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp +covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp +covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp +covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp +covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp +covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp +covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp +covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp +covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp +covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp ``` -## 操作 CovenantSQL +## Operate CovenantSQL + +### Create a database -### 创建数据库 +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. -使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 +e.g.: creating a single-node database instance ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` -> 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes ```shell -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -no-password '{"node":2}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` -命令会返回创建的数据库实例的连接串 +The command will return the connection string of the created database instance ```shell -covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -### 访问数据库 +### Accessing the database -使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```shell -docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml -no-password -dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` -会得到如下输出,并进入 `cql` 交互命令行模式 +After that, it will get the following output, and enter the `cql` interactive command line mode ```shell -Connected with driver covenantsql (develop-34ae741a-20190415135520) +Connected with driver covenantsql (develop) Type "help" for help. -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -`cql` 交互命令行模式的使用方法类似 `mysql` 命令,例如:创建一个名为 `test` 的表,查看数据库中的表,插入记录,查询结果 +The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. ```sql CREATE TABLE test (test TEXT); @@ -127,36 +128,36 @@ INSERT INTO test VALUES("happy"); SELECT * FROM test; ``` -会得到如下输出 +After that, it will get the following output: ```shell -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> CREATE TABLE test (test TEXT); +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SHOW TABLES; +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; name ------ test (1 row) -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> INSERT INTO test VALUES("happy"); +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); INSERT -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> SELECT * FROM test; +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; test ------- happy (1 row) -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -使用 `Ctrl + D` 快捷键或输入 `\q` 可以退出 `cql` 交互命令行 +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line ### SQLChain Observer -镜像中的 Observer 角色使用了和 mysql-adapter 镜像中相同的 private.key ,故可以免去新账户授权和转账的过程制。 +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. -(关于权限管理的详细说明请参考[数据库权限管理](cql.md#数据库权限管理)) +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) -#### 在浏览器使用 SQLChain Observer +#### Use SQLChain Observer in your browser -我们在 `127.0.0.1:11108` 端口提供了一个 SQLChain 的 Observer 可以看到 SQL 语句在链上的情况。 \ No newline at end of file +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From b94180abe2bbaa3055ac19ec91dd8f569159c09b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:12 +0800 Subject: [PATCH 180/421] New translations usecase.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/usecase.md | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase.md b/website/translated_docs/zh-CN/version-0.5.0/usecase.md index 9444a0c..fedfbe6 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase.md @@ -1,6 +1,39 @@ --- id: version-0.5.0-usecase -title: 使用案例 +title: Use case original_id: usecase --- -## TBD \ No newline at end of file +## Traditional App + +### Privacy data + +If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: + +1. Serverless: no need to deploy a server to store your user's password for sync which is the hot potato. +2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users. +3. Regulation: CQL naturally comply with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation). + +### IoT storage + +CQL miners are deployed globally, IoT node can write to nearest CQL miner directly. + +1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper. +2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable. + +### Open data service + +For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs. + +1. CQL can limit specific SQL query statements to meet the needs while also balancing data security; +2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing, like [this](https://explorer.dbhub.org/dbs/7a51191ae06afa22595b3904dc558d41057a279393b22650a95a3fc610e1e2df/requests/f466f7bf89d4dd1ece7849ef3cbe5c619c2e6e793c65b31966dbe4c7db0bb072) +3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates. + +### Secure storage + +Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs. + +* * * + +## ĐApp + +Storing data on Bitcoin or Ethereum is quite expensive ($4305 / MB on Ethereum 2018-05-15). Programming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world. \ No newline at end of file From 3e13df18112753922ae319c3cfd0107da6ff0b7e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:14 +0800 Subject: [PATCH 181/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quickstart.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 06eb95c..d3a34ba 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-quickstart -title: '🌏 TestNet 快速开始' +title: Quick Start original_id: quickstart --- ## CovenantSQL 工具包 @@ -87,8 +87,9 @@ cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ 命令执行耗时较长,大约 30s 之后控制台会输出: - covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 - +> covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + +​ 这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 From 97974f8a4b3ea2e4a06dfbc15d4f8b1584b6495f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:16 +0800 Subject: [PATCH 182/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/intro.md b/website/translated_docs/zh-CN/version-0.5.0/intro.md index dd9addc..0fa6d06 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/intro.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-intro -title: CovenantSQL 介绍 +title: CovenantSQL Intro original_id: intro --- From 51982d165bd962ee8843429f9f364804b1f1db70 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:17 +0800 Subject: [PATCH 183/421] New translations nav.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/nav.md | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/nav.md b/website/translated_docs/zh-CN/version-0.5.0/nav.md index 8597bac..5c472bd 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/nav.md +++ b/website/translated_docs/zh-CN/version-0.5.0/nav.md @@ -1,22 +1,32 @@ --- id: version-0.5.0-nav -title: '📖 使用导航' +title: 使用导航 original_id: nav --- -## 直接使用测试网 +## 快速开始 -[🌏 TestNet 快速开始](./quickstart) +[TestNet 快速开始](./quickstart) -## 部署私有 CovenantSQL 数据库(搭建私有链) +[CQL 操作手册](./cql) -如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: +## 开发应用 -[🐳 Docker 一键部署](./deployment) +[Golang](./driver_golang) + +[Java](./driver_java) + +[Python](./driver_python) + +[NodeJS](./driver_js) -## 使用 CovenantSQL 开发应用 +## 高级使用 -[📦 CovenantSQL SDK](./development) +#### 私有部署 + +如果您是企业用户,希望在自己的网络搭建 CovenantSQL 数据库服务,请参考: + +[🐳 Docker 一键部署](./deployment) -## CovenantSQL 联盟链解决方案 +#### 联盟链解决方案 -正在建设中,如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file +如需咨询请邮件至 webmaster@covenantsql.io。 \ No newline at end of file From 762cb8968e28d235317249229efdd538f28ccc01 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:19 +0800 Subject: [PATCH 184/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md index 880c26d..428ca40 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-cql -title: '🖥️ CQL 命令行工具集' +title: Client original_id: cql --- ## 简介 From f69d5d8c41bc071b20c0883d3643c38ad11d7439 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:20 +0800 Subject: [PATCH 185/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md index c910445..b820313 100644 --- a/website/translated_docs/zh-CN/qna.md +++ b/website/translated_docs/zh-CN/qna.md @@ -1,5 +1,5 @@ --- id: qna -title: '🙋 常见问题解答' +title: Q&A --- ## TBD \ No newline at end of file From 30a5f2fe2fd6750db1a9f7a3827618c169792193 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:21 +0800 Subject: [PATCH 186/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/intro.md b/website/translated_docs/zh-CN/intro.md index 2eab7a1..bcdec0e 100644 --- a/website/translated_docs/zh-CN/intro.md +++ b/website/translated_docs/zh-CN/intro.md @@ -1,6 +1,6 @@ --- id: intro -title: CovenantSQL 介绍 +title: CovenantSQL Intro --- From 556b42d609e7fb4aacb3159da7353d7ec02de582 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:23 +0800 Subject: [PATCH 187/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_js.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_js.md b/website/translated_docs/zh-CN/driver_js.md index a1f40e2..7f03e57 100644 --- a/website/translated_docs/zh-CN/driver_js.md +++ b/website/translated_docs/zh-CN/driver_js.md @@ -1,8 +1,8 @@ --- id: driver_js -title: '📦 Javascript' +title: JavaScript --- -## Use Javascript to access CovenantSQL +## Use JavaScript to access CovenantSQL Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). From 2f5783fc9c8764423f6421da80163c4bc2d27e33 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:24 +0800 Subject: [PATCH 188/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_golang.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/driver_golang.md b/website/translated_docs/zh-CN/driver_golang.md index c39b391..c3d2d84 100644 --- a/website/translated_docs/zh-CN/driver_golang.md +++ b/website/translated_docs/zh-CN/driver_golang.md @@ -1,6 +1,6 @@ --- id: driver_golang -title: '📦 Golang' +title: Golang --- ## Use Golang to access CovenantSQL From 5cfaf60f7d6292560951e22618b805ebd821e9d5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:26 +0800 Subject: [PATCH 189/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 0e70988..93d6f8d 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -1,6 +1,6 @@ --- id: quickstart -title: '🌏 TestNet 快速开始' +title: Quick Start --- ## CovenantSQL 工具包 @@ -86,8 +86,9 @@ cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ 命令执行耗时较长,大约 30s 之后控制台会输出: - covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 - +> covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + +​ 这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 From d0d188c4280ec6790ad7fe32cc7eec1ae4950d39 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:27 +0800 Subject: [PATCH 190/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index a6546f0..bf93a78 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -1,10 +1,10 @@ --- id: adapter -title: '📦 Adapter SDK' +title: Adapter --- # Use Adapter to access CovenantSQL -`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP Rest requests. +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. ## How to use From 827e1ad404a64d50a8c92e3472cc28af9b99e99a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:28 +0800 Subject: [PATCH 191/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 05e5f39..27d0176 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -1,6 +1,6 @@ --- id: driver_java -title: '📦 Java' +title: Java --- ## Use Java to access CovenantSQL From a340d3388e738bfafa8467c49600886e2b774df0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:29 +0800 Subject: [PATCH 192/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_python.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md index e1192ed..c273518 100644 --- a/website/translated_docs/zh-CN/driver_python.md +++ b/website/translated_docs/zh-CN/driver_python.md @@ -1,6 +1,6 @@ --- id: driver_python -title: '📦 Python' +title: Python --- ## Use Python to access CovenantSQL @@ -8,7 +8,7 @@ Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-drive ### Compatibility -`Python SDK` requires `python 3.4+`. +`Python SDK` requires `Python 3.4+`. ### Installation and quick start From 357d21308f4aecdbc3cbd9200fbe35e54edc4c9e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:31 +0800 Subject: [PATCH 193/421] New translations deployment-en.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/deployment-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md index adfe539..b97f767 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-deployment -title: '🐳 Docker one-line deployment' +title: Docker one-line deployment original_id: deployment --- ## Deploy with CovenantSQL Docker From 27b41e62d28fc6cd2b5c6fa85302ab5bc759f780 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:32 +0800 Subject: [PATCH 194/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_js.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_js.md b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md index 4012c58..4cd7824 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_js.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md @@ -1,9 +1,9 @@ --- id: version-0.5.0-driver_js -title: '📦 Javascript' +title: JavaScript original_id: driver_js --- -## Use Javascript to access CovenantSQL +## Use JavaScript to access CovenantSQL Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). From 275321ba1d41d8d227c38c191ddc112812f2c10b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:34 +0800 Subject: [PATCH 195/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_golang.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md index 13f9632..f3bd07a 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-driver_golang -title: '📦 Golang' +title: Golang original_id: driver_golang --- ## Use Golang to access CovenantSQL From 77d7349741bb460a4143467fae84d81d2dd7fca8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:35 +0800 Subject: [PATCH 196/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_python.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md index d9a537c..db5defa 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-driver_python -title: '📦 Python' +title: Python original_id: driver_python --- ## Use Python to access CovenantSQL @@ -9,7 +9,7 @@ Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-drive ### Compatibility -`Python SDK` requires `python 3.4+`. +`Python SDK` requires `Python 3.4+`. ### Installation and quick start From 49988af441e56a1186fba694ce20b6d6c3524862 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:36 +0800 Subject: [PATCH 197/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_java.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index 894d538..926f79a 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-driver_java -title: '📦 Java' +title: Java original_id: driver_java --- ## Use Java to access CovenantSQL From 48676bef1f507b73ef1588e52a3ca116790d32c1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 16:57:38 +0800 Subject: [PATCH 198/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/adpater.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md index 24dbf68..fb28e3c 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/adpater.md +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -1,11 +1,11 @@ --- id: version-0.5.0-adapter -title: '📦 Adapter SDK' +title: Adapter original_id: adapter --- # Use Adapter to access CovenantSQL -`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP Rest requests. +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. ## How to use From b5858679314953fda761f8cf6f4018d285daa29d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:47 +0800 Subject: [PATCH 199/421] New translations usecase_dapp.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase_dapp.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 website/translated_docs/zh-CN/usecase_dapp.md diff --git a/website/translated_docs/zh-CN/usecase_dapp.md b/website/translated_docs/zh-CN/usecase_dapp.md new file mode 100644 index 0000000..4da8c66 --- /dev/null +++ b/website/translated_docs/zh-CN/usecase_dapp.md @@ -0,0 +1,5 @@ +--- +id: usecase_dapp +title: DApp +--- +Storing data on Bitcoin or Ethereum is quite expensive ($4305 / MB on Ethereum 2018-05-15). Programming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world. \ No newline at end of file From 77d6c349b814d1d622ffdc44ec5a51d4ddaa21b1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:48 +0800 Subject: [PATCH 200/421] New translations usecase_traditional_app.md (Chinese Simplified) --- .../zh-CN/usecase_traditional_app.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 website/translated_docs/zh-CN/usecase_traditional_app.md diff --git a/website/translated_docs/zh-CN/usecase_traditional_app.md b/website/translated_docs/zh-CN/usecase_traditional_app.md new file mode 100644 index 0000000..6a746a0 --- /dev/null +++ b/website/translated_docs/zh-CN/usecase_traditional_app.md @@ -0,0 +1,30 @@ +--- +id: usecase_traditional_app +title: Traditional App +--- +### Privacy data + +If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: + +1. Serverless: no need to deploy a server to store your user's password for sync which is the hot potato. +2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users. +3. Regulation: CQL naturally comply with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation). + +### IoT storage + +CQL miners are deployed globally, IoT node can write to nearest CQL miner directly. + +1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper. +2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable. + +### Open data service + +For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs. + +1. CQL can limit specific SQL query statements to meet the needs while also balancing data security; +2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing, like [this](https://explorer.dbhub.org/dbs/7a51191ae06afa22595b3904dc558d41057a279393b22650a95a3fc610e1e2df/requests/f466f7bf89d4dd1ece7849ef3cbe5c619c2e6e793c65b31966dbe4c7db0bb072) +3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates. + +### Secure storage + +Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs. \ No newline at end of file From 600b17debebb0b1ef9dc4ff2d7d28eb2a68d78f0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:51 +0800 Subject: [PATCH 201/421] New translations usecase_data_analysis.md (Chinese Simplified) --- .../zh-CN/usecase_data_analysis.md | 297 ++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 website/translated_docs/zh-CN/usecase_data_analysis.md diff --git a/website/translated_docs/zh-CN/usecase_data_analysis.md b/website/translated_docs/zh-CN/usecase_data_analysis.md new file mode 100644 index 0000000..0569201 --- /dev/null +++ b/website/translated_docs/zh-CN/usecase_data_analysis.md @@ -0,0 +1,297 @@ +--- +id: usecase_data_analysis +title: Data Analysis +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From beb28be8eac132b2a2aa6f10b2fa399e2a05779c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:52 +0800 Subject: [PATCH 202/421] New translations usecase_dapp.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md new file mode 100644 index 0000000..6436350 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md @@ -0,0 +1,6 @@ +--- +id: version-0.5.0-usecase_dapp +title: DApp +original_id: usecase_dapp +--- +Storing data on Bitcoin or Ethereum is quite expensive ($4305 / MB on Ethereum 2018-05-15). Programming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world. \ No newline at end of file From 8dfcbacab8244cb5913ceec757dd7abe12785c64 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:55 +0800 Subject: [PATCH 203/421] New translations usecase_data_analysis.md (Chinese Simplified) --- .../version-0.5.0/usecase_data_analysis.md | 298 ++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md new file mode 100644 index 0000000..3d70ac6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md @@ -0,0 +1,298 @@ +--- +id: version-0.5.0-usecase_data_analysis +title: Data Analysis +original_id: usecase_data_analysis +--- +## 关于 Quandl + +Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 + +## Quandl 数据索引 + +### CovenantSQL 使用简介 + +首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 + +现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 + +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) + +所需参数: + + host: 'e.morenodes.com' + port: 11108 + database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' + + +### 数据使用方法 + +Quandl 数据分为表以及子表两层索引 + +数据库中,表名为`quandl_` + `database_code`为完整表名 + +通过查询表名来查看表的内容 + +具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) + +使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 + +### 查询示例 + +1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: + + `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` + +2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 + + 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 + + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania + + 于是,我们可以用以下方式把这个子表给查询出来 + + `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` + +3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + +## Quandl 数据 Excel 插件使用说明 + +您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + +### 配置 Excel 插件 + +解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 + +#### 修改 xml 配置 + +每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: + +```xml + + + + + + + + + +``` + +其中有如下配置需要修改,并保存: + +- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 + +#### 安装插件 + +有两种办法使用此 Excel 插件 + +1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 + +![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) + +如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 + +2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: + +![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) + +#### 使用插件 + +选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: + +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) + +- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 + +- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 + +- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 + +- 蓝色部分是导出数据的可选项 + + - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 + - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) + +现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 + +## 附件表 + +| DataBase | 名称 | 描述 | +| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | +| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | +| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | +| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | +| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | +| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | +| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | +| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | +| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | +| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | +| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | +| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | +| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | +| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | +| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | +| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | +| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | +| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | +| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | +| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | +| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | +| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | +| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | +| GDT | 全球乳品贸易数据 | nan | +| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | +| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | +| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | +| LOCALBTC | Local Bitcoins数据 | nan | +| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | +| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | +| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | +| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | +| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | +| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | +| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | +| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | +| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | +| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | +| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | +| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | +| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | +| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | +| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | +| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | +| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | +| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | +| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | +| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | +| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | +| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | +| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | +| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | +| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | +| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | +| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | +| CEGH | 中欧天然气中心数据 | nan | +| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | +| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | +| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | +| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | +| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | +| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | +| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | +| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | +| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | +| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | +| GPP | 全球石油价格 | nan | +| PPE | 波兰电力交易所(TGE)数据 | nan | +| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | +| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | +| WSE | 华沙证券交易所(GPW)数据 | nan | +| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | +| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | +| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | +| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | +| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | +| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | +| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | +| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | +| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | +| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | +| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | +| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | +| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | +| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | +| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | +| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | +| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | +| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | +| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | +| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | +| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | +| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | +| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | +| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | +| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | +| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | +| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | +| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | +| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | +| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | +| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | +| MAS | 新加坡金融管理局数据 | nan | +| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | +| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | +| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | +| UKR | 乌克兰交易所数据 | nan | +| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | +| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | +| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | +| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | +| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | +| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | +| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | +| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | +| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | +| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | +| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | +| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | +| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | +| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | +| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | +| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | +| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | +| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | +| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | +| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | +| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | +| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | +| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | +| NAHB | 美国住房指数 | 美国的住房和经济指数。 | +| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | +| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | +| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | +| MULTPL | S&P 500 | nan | +| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | +| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | +| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | +| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | +| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | +| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | +| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | +| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | +| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | +| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | +| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | +| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | +| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | +| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | +| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | +| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | +| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | +| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | +| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | +| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | +| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | +| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | +| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | +| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | +| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | +| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | +| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | +| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | +| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | +| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | +| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | +| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | +| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | +| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | +| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | +| BOJ | 日本银行数据 | nan | +| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | +| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | +| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | +| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file From d03a63fe5f7fcaf5dea4e28dba4a7417df4d01c9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:07:57 +0800 Subject: [PATCH 204/421] New translations usecase_traditional_app.md (Chinese Simplified) --- .../version-0.5.0/usecase_traditional_app.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md new file mode 100644 index 0000000..d42cd24 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md @@ -0,0 +1,31 @@ +--- +id: version-0.5.0-usecase_traditional_app +title: Traditional App +original_id: usecase_traditional_app +--- +### Privacy data + +If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: + +1. Serverless: no need to deploy a server to store your user's password for sync which is the hot potato. +2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users. +3. Regulation: CQL naturally comply with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation). + +### IoT storage + +CQL miners are deployed globally, IoT node can write to nearest CQL miner directly. + +1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper. +2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable. + +### Open data service + +For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs. + +1. CQL can limit specific SQL query statements to meet the needs while also balancing data security; +2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing, like [this](https://explorer.dbhub.org/dbs/7a51191ae06afa22595b3904dc558d41057a279393b22650a95a3fc610e1e2df/requests/f466f7bf89d4dd1ece7849ef3cbe5c619c2e6e793c65b31966dbe4c7db0bb072) +3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates. + +### Secure storage + +Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs. \ No newline at end of file From f9d053ed08ad74ff476525793d05b64605c2e6c0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:56:43 +0800 Subject: [PATCH 205/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql.md | 872 +++++++++++++-------------- 1 file changed, 426 insertions(+), 446 deletions(-) diff --git a/website/translated_docs/zh-CN/cql.md b/website/translated_docs/zh-CN/cql.md index c73b324..c47f8e7 100644 --- a/website/translated_docs/zh-CN/cql.md +++ b/website/translated_docs/zh-CN/cql.md @@ -2,177 +2,175 @@ id: cql title: Client --- -## 简介 +## Intro -CovenantSQL 为终端用户提供 `cql` 命令行工具集,用于对用户账号、钱包以及名下的数据库进行便捷的管理和访问操作。~~工具下载地址见 [release](https://github.com/CovenantSQL/CovenantSQL/releases) 页面。请将 `cql` 二进制解压到自己系统 PATH 路径里以方便调用。~~(补充:使用包管理工具安装 `cql`)。 +CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). -### 账号私钥和配置文件 +### Private Key and Config File -运行 `cql` 依赖私钥文件 `private.key` 和配置文件 `config.yaml`,其中: +The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: -- `private.key`:生成用户账户时所分配的私钥,请务必妥善保管好这个私钥 -- `config.yaml`:主要用于配置 `cql` 命令要连接的 CovenantSQL 网络(如 TestNet 或用户使用 [Docker 一键部署](deployment)的网络) +- `private.key`:a private key file which is generated while creating an account, be sure to keep it safe +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) -出于安全方面的考虑,私钥文件通常需要使用主密码进行加密。主密码在创建账号时由用户输入,之后由用户自行记忆或保管,而不会保存到配置文件中。当需要使用到私钥的时候,`cql` 命令会要求用户输入主密码以解开私钥文件。 +For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. -### 子命令通用参数 +### Common Parameters for Sub-commands -以下列出子命令中使用到的通用参数: +The following parameters are commonly used by `cql` sub-commands: -```bash - -bypass-signature - 禁用签名和验签,仅用于开发者测试 - -config string - 指定配置文件路径,默认值为 "~/.cql/config.yaml" - -no-password - 使用空白主密码加密私钥 - -password string - 私钥主密码(不安全,仅用于调试或安全环境下的脚本模式) -``` + -bypass-signature + Disable signature signing and verifying, for testing only + -config string + Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") + -no-password + Use an empty master key + -password string + Master key for covenantsql (NOT SAFE, for debugging or script mode only) + -注意,因为私钥文件的路径是在配置文件中设定的,默认值为相对路径 `./private.key`,即配置文件的同一目录下,所以我们通常把私钥和配置文件放置到同一目录下,而不设置单独的参数来指定私钥文件。 +Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. -## 账号管理 +## Account Management -对于 TestNet 环境,我们提供了一个公用的测试账号私钥及配置文件用于快速接入测试,详情请参见 [CovenantSQL TestNet](quickstart) 快速上手教程。另外你也可以选择参照如下教程在本地创建新账号。 +For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. -### 创建新账号 +### Creating New Account -子命令 `generate` 在指定目录生成私钥及指向 TestNet 的配置文件,示例: +The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: ```bash cql generate config ``` -> 目前默认生成的配置文件指向测试网,还需要提供生成指向 Docker 一键部署网络的配置方法。 +> Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. -指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 +For a complete help message, check [Complete Parameters](#sub-command-generate-complete-parameters). -输出: +Output: -```bash -Generating key pair... -Enter master key(press Enter for default: ""): - -Private key file: ~/.cql/private.key -Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 -Generated key pair. -Generating nonce... -INFO[0075] cpu: 4 -INFO[0075] position: 3, shift: 0x0, i: 3 -INFO[0075] position: 1, shift: 0x0, i: 1 -INFO[0075] position: 0, shift: 0x0, i: 0 -INFO[0075] position: 2, shift: 0x0, i: 2 -nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} -node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 -Generated nonce. -Generating config file... -Generated nonce. -``` + Generating key pair... + Enter master key(press Enter for default: ""): + + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + -### 获取私钥文件的公钥 +### Acquiring the Public Key -子命令 `generate` 也可以用来获取已经存在的私钥文件对应的公钥十六进制串。示例: +The sub-command `generate` is also used to acquire the public key (in hex string format) of the private key file, e.g.: ```bash cql generate public ``` -输出: +Output: -```bash -Enter master key(press Enter for default: ""): - -INFO[0011] init config success path=/home/levente/.cql/private.key -INFO[0011] use public key in config file: /home/levente/.cql/config.yaml -Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 -``` + Enter master key(press Enter for default: ""): + + INFO[0011] init config success path=/home/levente/.cql/private.key + INFO[0011] use public key in config file: /home/levente/.cql/config.yaml + Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 + -> 这一功能实际使用过程中暂时不会用到 +> This functionality is usually not used in common scene -### 子命令 `generate` 完整参数 +### Sub-command `generate` Complete Parameters -通用参数部分参考 [子命令通用参数](#子命令通用参数),以下介绍其他子命令时不再另外说明。 +Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this in the further sub-command introductions. -特殊地,在使用 `cql generate config` 命令生成新账号配置时,`-config`、`-no-password` 和 `-password` 等参数实际作用于将要生成的新私钥和配置文件,而不是要读取的文件。 + usage: cql generate [parameters]... config | public + + Generate command can generate private.key and config.yaml for CovenantSQL. + e.g. + cql generate config + + Params: + + -```bash -usage: cql generate [参数]... config | public +### Mine a Node ID -生成新私钥及配置文件,或获取指定配置的私钥文件对应的公钥。 - -Params: - 没有额外参数 -``` - -### 计算 Node ID - -子命令 `idminer` 用于计算指定配置文件(对应的私钥)的 Node ID(Node ID 的相关知识请参考[链接](terms#Node-ID))。示例: +The sub-command `idminer` is used to mine another Node ID of a private key (specified by a config file), (also check [Node ID](terms#Node-ID) for details). e.g.: ```bash cql idminer ``` -输出: - -```bash -INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 -Enter master key(press Enter for default: ""): - -INFO[0008] init config success path=/home/levente/.cql/config.yaml -INFO[0008] use public key in config file: /home/levente/.cql/config.yaml -INFO[0008] cpu: 8 -INFO[0008] position: 3, shift: 0x20, i: 7 -INFO[0008] position: 0, shift: 0x0, i: 0 -INFO[0008] position: 3, shift: 0x0, i: 6 -INFO[0008] position: 1, shift: 0x0, i: 2 -INFO[0008] position: 2, shift: 0x0, i: 4 -INFO[0008] position: 1, shift: 0x20, i: 3 -INFO[0008] position: 2, shift: 0x20, i: 5 -INFO[0008] position: 0, shift: 0x20, i: 1 -nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} -node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e -``` - -> 这一功能实际使用过程中暂时不会用到 - -### 子命令 `idminer` 完整参数 - -```bash -usage: cql idminer [-config file] [-difficulty number] [-loop false] - -为指定配置的私钥文件计算新的 Node ID。 - -Params: - -difficulty int - 生成 Node ID 的难度要求,默认值为 24 - -loop - 循环计算以取得更高难度的 Node ID -``` - -## 钱包管理 - -### 查看钱包地址 - -在配置好账号以后,可以通过 `wallet` 子命令来获取账号的钱包地址: +Output: + + INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 + Enter master key(press Enter for default: ""): + + INFO[0008] init config success path=/home/levente/.cql/config.yaml + INFO[0008] use public key in config file: /home/levente/.cql/config.yaml + INFO[0008] cpu: 8 + INFO[0008] position: 3, shift: 0x20, i: 7 + INFO[0008] position: 0, shift: 0x0, i: 0 + INFO[0008] position: 3, shift: 0x0, i: 6 + INFO[0008] position: 1, shift: 0x0, i: 2 + INFO[0008] position: 2, shift: 0x0, i: 4 + INFO[0008] position: 1, shift: 0x20, i: 3 + INFO[0008] position: 2, shift: 0x20, i: 5 + INFO[0008] position: 0, shift: 0x20, i: 1 + nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} + node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e + + +> This functionality is usually not used in common scene + +### Sub-command `idminer` Complete Parameters + + usage: cql idminer [parameter]... + + IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + e.g. + cql idminer -difficulty 24 + + If you want to mine a good id, use: + cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 + + Params: + -difficulty int + the difficulty for a miner to mine nodes and generating a nonce (default 24) + -loop + mining endless loop + + +## Wallet Management + +### Wallet Address + +Once the private key and config file is set, we can use sub-command `wallet` to check the wallet address of the account: ```bash cql wallet ``` -输出: +Output: -```bash -Enter master key(press Enter for default: ""): + Enter master key(press Enter for default: ""): + + wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 + -wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -``` - -这里可以看到我们用于测试的账号私钥文件对应的钱包地址是 `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`。 +The wallet address of the test account here is `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`. -### 查看钱包余额 +### Wallet Balances -获得钱包地址之后,就可以使用 `wallet` 子命令来查看你的钱包余额了。目前 CovenantSQL 支持的代币类型为以下 5 种: +We can also use sub-command `wallet` to check the balances in the wallet. CovenantSQL currently supports 5 types of tokens: - `Particle` - `Wave` @@ -180,182 +178,178 @@ wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 - `Ether` - `EOS` -其中 `Particle` 和 `Wave` 为 CovenantSQL 默认使用的代币,查看默认代币余额的命令为: +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. To check the token balances, use: ```bash cql wallet -balance all ``` -输出: +Output: -```bash -INFO[0000] Particle balance is: 10000000000000000000 -INFO[0000] Wave balance is: 10000000000000000000 -``` + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + -也可以单独指定代币类型,如查看 `Bitcoin` 余额: +You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: ```bash cql wallet -balance Bitcoin ``` -输出: +Output: -```bash -INFO[0000] Bitcoin balance is: 0 -``` + INFO[0000] Bitcoin balance is: 0 + -### 向其他账号转账 +### Transferring Tokens to Another Account -从 [TestNet](quickstart) 获得代币或 [Docker 一键部署](deployment)的网络获得代币后,可以使用 `transfer` 命令来向其他账号转账。转账操作使用 `json` 格式的转账信息作为参数,例如: +Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: ```json { - "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 - "amount": "1000000 Particle" // 转账金额并带上单位 + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Receiver wallet address + "amount": "1000000 Particle" // Transfer amount with token type } ``` -其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 - -把以上参数传给 `transfer` 子命令来进行转账: +Note that the receiver wallet address could be a user account address or a database address -- we treat the database as a special kind of account. While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. -```bash -cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' -``` +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). -输出: +Pass the parameter to `transfer`: ```bash -INFO[0000] succeed in sending transaction to CovenantSQL +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' ``` -注意,以上输出信息只说明交易请求已经成功发送至 CovenantSQL 网络,需要等待 BP 节点执行并确认交易后才能实际生效。交易能否成功、何时成功可以通过执行 `cql wallet -balance ` 来确定,也可以在执行命令时添加 `-wait-tx-confirm` 参数来让 `cql` 命令查询到执行结果之后再退出。 - -### 子命令 `wallet` 完整参数 +Output: -```bash -usage: cql wallet [-config file] [-balance token_type] + INFO[0000] succeed in sending transaction to CovenantSQL + -查看账号钱包地址和代币余额。 -示例: - cql wallet - cql wallet -balance Particle - cql wallet -balance all +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -balance ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. -Params: - -balance string - 获取当前账号中指定代币类型的余额 -``` - -### 子命令 `transfer` 完整参数 - -```bash -usage: cql transfer [-config file] [-wait-tx-confirm] meta_json +### Sub-command `wallet` Complete Parameters -向目标账号地址进行转账。输入参数为 JSON 格式的转账交易数据。 -示例: - cql transfer '{"addr": "your_account_addr", "amount": "100 Particle"}' + usage: cql wallet [-config file] [-balance token_name] + + Wallet command can get CovenantSQL wallet address and the token balance of the current account + e.g. + cql wallet + + cql wallet -balance Particle + cql wallet -balance all + + Params: + -balance string + Get a specific token's balance of the current account, e.g. Particle, Wave, and etc. + -由于 CovenantSQL 是区块链上的数据库,在交易生效之前你可能需要等待执行确认。 -示例: - cql transfer -wait-tx-confirm '{"addr": "your_account_addr", "amount": "100 Particle"}' +### Sub-command `transfer` Complete Parameters -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` + usage: cql transfer [-config file] [-wait-tx-confirm] meta_json + + Transfer command can transfer your token to the target account. + The command argument is JSON meta info of a token transaction. + e.g. + cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + + Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + e.g. + cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + -## 数据库管理 +## Database Management -### 创建数据库 +### Creating Database -创建数据库与 `transfer` 子命令类似使用 `json` 格式的输入参数,创建由一个节点组成的数据库: +Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: ```bash cql create '{"node": 1}' ``` -输出: - -```bash -Enter master key(press Enter for default: ""): +Output: -covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 -``` + Enter master key(press Enter for default: ""): + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + -注意这里生成的 `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 即为数据库的连接字符串(dsn),其中 `covenantsql` 为数据库协议字段,一般也可以缩写为 `cql`;`//` 后的十六进制串为数据库地址,可以在 `transfer` 子命令中作为收款地址使用。 +Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. -子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 +The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. -关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 +For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). -### ~~删除数据库~~ +### ~~Deleting Database~~ -~~未实现。~~ +~~Not yet implemented.~~ -### 数据库权限管理 +### Granting Permission -#### 访问权限 +#### Access Permission -CovenantSQL 数据库有三类库级别权限: +CovenantSQL database has 3 kinds of access permission: - `Admin` - `Write` - `Read` -- `Void` +- `Void` (for none) -其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。 +Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. -假设我们用默认账号创建好了数据库 `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5`,在目录 `account2` 下创建好新账号配置,账号地址为 `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`,现在用默认账号给新账号授权已经创建好的数据库的访问权限,同样使用 `json` 格式的授权信息为参数: +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following: ```json { - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 - "perm": "Read,Write" // 权限内容,多个权限用英文逗号隔开 + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission + "perm": "Read,Write" // Permission, separated by commas } ``` -把以上参数传给 `grant` 子命令来增加读写权限: +Pass the parameter to `grant`: ```bash cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' ``` -输出: +Output: -```bash -INFO[0000] succeed in sending transaction to CovenantSQL -``` + INFO[0000] succeed in sending transaction to CovenantSQL + -吊销权限: +Or revoke the permission: ```bash cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' ``` -输出: +Output: -```bash -INFO[0000] succeed in sending transaction to CovenantSQL -``` + INFO[0000] succeed in sending transaction to CovenantSQL + -子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 +The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. -由于目前每个数据库实例分别为每个用户独立计费,所以为数据库添加新的账户权限后,需要以新账户身份向该数据库转押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 +Since the database separately keeps billing for each user, you need to transfer tokens to the database (as user deposit and advance payment) from the new account before it can actually get access to the database. The minimum amount of deposit and advance payment can be calculated by: `gas_price*number_of_miner*120000`. -使用新账户给数据库充值: +Transferring from `account2` to the database: ```bash cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' ``` -#### SQL 白名单 +#### SQL White List -CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除或更新操作。 +CovenantSQL supports white list setting for each of its users. By setting up SQL white list, you can further limit the access permission of a user to a given list of SQL Patterns with assignable parameters. With this feature, your database can be further secured because it avoids important data breach and accidentally updating/deleting. -增加白名单: +Adding a white list: ```bash cql grant ' @@ -373,11 +367,9 @@ cql grant ' ' ``` -*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* - -设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a` 的总数据量。 +*SQL White List is an extension of the database permission system. It currently doesn't support incrementally updating, so you need to provide the complete permission information each time you use the `grant` sub-command* -去掉白名单限制: +Cleaning the white list: ```bash cql grant ' @@ -400,244 +392,232 @@ cql grant ' ' ``` -将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 - -### 子命令 `create` 完整参数 - -```bash -usage: cql create [-config file] [-wait-tx-confirm] db_meta_json - -为当前账号创建数据库实例,输入参数为 JSON 格式的创建交易数据,其中节点数 node 为必带字段。 -示例: - cql create '{"node": 2}' - -完整的 db_meta_json 字段解释如下: - targetminers []string // 目标节点的账号地址 - node int // 目标节点数 - space int // 需要的硬盘空间,0 为任意 - memory int // 需要的内存空间,0 为任意 - loadavgpercpu float // 需要的 CPU 资源占用,0 为任意 - encryptionkey string // 落盘加密密钥 - useeventualconsistency bool // 各个数据库节点之间是否使用最终一致性同步 - consistencylevel float // 一致性级别,通过 node*consistencylevel 得到强同步的节点数 - isolationlevel int // 单个节点上的隔离级别,默认级别为线性级别 - -由于 CovenantSQL 是区块链上的数据库,在真正访问数据库之前你可能需要等待创建请求的执行确认以及在数据库节点上的实际创建。 -示例: - cql create -wait-tx-confirm '{"node": 2}' - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -### 子命令 `drop` 完整参数 - -```bash -usage: cql drop [-config file] [-wait-tx-confirm] dsn/dbid - -通过数据库的连接字符串或账号地址来删除数据库。 -示例: - cql drop the_dsn_of_your_database - -由于 CovenantSQL 是区块链上的数据库,在删除操作生效之前你可能需要等待删除请求的执行确认以及在数据库节点上的实际执行。 -示例: - cql drop -wait-tx-confirm the_dsn_of_your_database - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -### 子命令 `grant` 完整参数 - -```bash -usage: cql grant [-config file] [-wait-tx-confirm] permission_meta_json - -为指定账号进行数据库权限授权。 -示例: - cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - -由于 CovenantSQL 是区块链上的数据库,在授权操作生效之前你可能需要等待授权请求的执行确认以及在数据库节点上的实际更新。 -示例 - cql grant -wait-tx-confirm '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -## 访问数据库 - -完成数据库的创建后,就可以使用 `console` 子命令来对数据库进行交互式的命令行访问了: +Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. + +### Sub-command `create` Complete Parameters + + usage: cql create [parameters]... db_meta_json + + Create CovenantSQL database by database meta info JSON string, meta info must include node count. + e.g. + cql create '{"node":2}' + + A complete introduction of db_meta_json fields: + targetminers []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + loadavgpercpu float // Minimum idle CPU requirement, 0 for none + encryptionkey string // Encryption key for persistence data + useeventualconsistency bool // Use eventual consistency to sync among miner nodes + consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency + isolationlevel int // Isolation level in a single node + + Since CovenantSQL is blockchain database, you may want get confirm of creation. + e.g. + cql create -wait-tx-confirm '{"node": 2}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +### Sub-command `drop` Complete Parameters + + usage: cql drop [parameter]... dsn/dbid + + Drop command can drop a database by DSN or database id + e.g. + cql drop covenantsql://the_dsn_of_your_database + + Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + e.g. + cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +### Sub-command `grant` Complete Parameters + + usage: cql grant [parameter]... permission_meta_json + + Grant command can give a user some specific permissions on your database + e.g. + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + + Since CovenantSQL is blockchain database, you may want get confirm of permission update. + e.g. + cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Accessing Database + +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: ```bash cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` -输出 - -```bash -Enter master key(press Enter for default: ""): +Output: -INFO[0010] init config success path=/home/levente/.cql/config.yaml -INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" -Connected with driver covenantsql (develop-34ae741a-20190416184528) -Type "help" for help. + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -或者使用以授权的账号来连接: +Or access as `account2` if it has successfully been granted access permission: ```bash cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` -输出 - -```bash -Enter master key(press Enter for default: ""): - -INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml -INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" -Connected with driver covenantsql (develop-34ae741a-20190416184528) -Type "help" for help. - -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -交互式访问示例: - -```bash -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); -CREATE TABLE -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); -INSERT -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; -c1 ----- -1 -2 -3 -(3 rows) - -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -### 子命令 `console` 完整参数 - -子命令 `console` 同时也支持在后台启动 `adapter` 和 `explorer` 服务,关于这些服务的相关说明请参考 [本地服务](#本地服务) 的相关章节。 - -```bash -usage: cql console [-config file] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] - -为 CovenantSQL 运行交互式的命令行访问。 -示例: - cql console -dsn the_dsn_of_your_database - -另外也可以通过 -command 参数来直接运行 SQL 查询语句或通过 -file 参数来从文件读取查询语句。 -在指定了这些参数的情况下 `console` 子命令将会直接执行命令后退出,而不会进入交互式的命令行模式。 -示例: - cql console -dsn the_dsn_of_your_database -command "create table test1(test2 int);" - -Params: - -adapter string - 指定数据库子链的 adapter 服务器的监听地址 - -command string - 执行单条 SQL 语句并退出 - -dsn string - 数据库连接字符串 - -explorer string - 指定数据库子链的 explorer 服务器监听地址 - -file string - 执行 SQL 脚本中的语句并退出 - -no-rc - 启动时不加载 .rc 初始脚本 - -out string - 指定输出文件 - -single-transaction - 在非交互模式下使用单个事务执行所有语句 - -variable value - 设置环境变量 -``` - -## 本地服务 - -### 子命令 `explorer` 完整参数 - -```bash -usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address - -为数据库子链运行 adapter 服务器。 -示例: - cql explorer 127.0.0.1:8546 - -Params: - -bg-log-level string - 后台服务日志级别 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -### 子命令 `mirror` 完整参数 - -```bash -usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address - -为数据库子链运行 mirror 服务器。 -示例: - cql mirror database_id 127.0.0.1:9389 - -Params: - -bg-log-level string - 后台服务日志级别 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -### 子命令 `adapter` 完整参数 - -关于 `adapter` 服务的说明请参考 。 - -```bash -usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address - -为数据库子链运行 adapter 服务器。 -示例: - cql adapter 127.0.0.1:7784 - -Params: - -bg-log-level string - 后台服务日志级别 - -mirror string - 指定镜像 adapter 服务器地址 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -## 高级使用 - -子命令 `rpc` 直接在 CovenantSQL 网络上进行 RPC 调用。 - -### 子命令 `rpc` 完整参数 - -```bash -usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request - -向目标服务器发送 RPC 请求。 -示例: - cql rpc -name 'MCC.QuerySQLChainProfile' \ - -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ - -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' - -Params: - -endpoint string - 目标 RPC Node ID - -name string - 目标 RPC 服务.方法名 - -req string - RPC 请求数据,JSON 格式 - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` \ No newline at end of file +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +### Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [parameter]... + + Console command can run a interactive SQL console for CovenantSQL + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database + + There is also a -command param for SQL script, and a -file param for reading SQL in a file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + + Params: + -adapter string + Address to serve a database chain adapter, e.g.:7784 + -command string + Run only single command (SQL or usql internal command) and exit + -dsn string + Database url + -explorer string + Address to serve a database chain explorer, e.g.:8546 + -file string + Execute commands from file and exit + -no-rc + Do not read startup file + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable + + +## Local Servers + +### Sub-command `explorer` Complete Parameter + + usage: cql explorer [parameter]... address + + Explorer command serves a SQLChain web explorer. + e.g. + cql explorer 127.0.0.1:8546 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +### Sub-command `mirror` Complete Parameter + + usage: cql mirror [parameter]... dsn/dbid address + + Mirror command subscribes database updates and serves a read-only database mirror. + e.g. + cql mirror database_id 127.0.0.1:9389 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +### Sub-command `adapter` Complete Parameter + +See for details of adapter server. + + usage: cql adapter [parameter]... address + + Adapter command serves a SQLChain adapter + e.g. + cql adapter 127.0.0.1:7784 + + Params: + -bg-log-level string + Background service log level + -mirror string + mirror server for the target adapter to query + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Advance Usage + +Sub-command `rpc` calls the remote process directly in the CovenantSQL network. + +### Sub-command `rpc` Complete Parameter + + usage: cql rpc [parameter]... + + Rpc command make a RPC request to the target server + e.g. + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + + Params: + -endpoint string + RPC endpoint to do a test call + -name string + RPC name to do a test call + -req string + RPC request to do a test call, in json format + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From f2e2fe02eb094d7167c59f646a23e1252c0c4872 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 18 Apr 2019 17:57:04 +0800 Subject: [PATCH 206/421] New translations cql.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql.md | 872 +++++++++--------- 1 file changed, 426 insertions(+), 446 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md index 428ca40..00ef48f 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -3,177 +3,175 @@ id: version-0.5.0-cql title: Client original_id: cql --- -## 简介 +## Intro -CovenantSQL 为终端用户提供 `cql` 命令行工具集,用于对用户账号、钱包以及名下的数据库进行便捷的管理和访问操作。~~工具下载地址见 [release](https://github.com/CovenantSQL/CovenantSQL/releases) 页面。请将 `cql` 二进制解压到自己系统 PATH 路径里以方便调用。~~(补充:使用包管理工具安装 `cql`)。 +CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). -### 账号私钥和配置文件 +### Private Key and Config File -运行 `cql` 依赖私钥文件 `private.key` 和配置文件 `config.yaml`,其中: +The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: -- `private.key`:生成用户账户时所分配的私钥,请务必妥善保管好这个私钥 -- `config.yaml`:主要用于配置 `cql` 命令要连接的 CovenantSQL 网络(如 TestNet 或用户使用 [Docker 一键部署](deployment)的网络) +- `private.key`:a private key file which is generated while creating an account, be sure to keep it safe +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) -出于安全方面的考虑,私钥文件通常需要使用主密码进行加密。主密码在创建账号时由用户输入,之后由用户自行记忆或保管,而不会保存到配置文件中。当需要使用到私钥的时候,`cql` 命令会要求用户输入主密码以解开私钥文件。 +For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. -### 子命令通用参数 +### Common Parameters for Sub-commands -以下列出子命令中使用到的通用参数: +The following parameters are commonly used by `cql` sub-commands: -```bash - -bypass-signature - 禁用签名和验签,仅用于开发者测试 - -config string - 指定配置文件路径,默认值为 "~/.cql/config.yaml" - -no-password - 使用空白主密码加密私钥 - -password string - 私钥主密码(不安全,仅用于调试或安全环境下的脚本模式) -``` + -bypass-signature + Disable signature signing and verifying, for testing only + -config string + Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") + -no-password + Use an empty master key + -password string + Master key for covenantsql (NOT SAFE, for debugging or script mode only) + -注意,因为私钥文件的路径是在配置文件中设定的,默认值为相对路径 `./private.key`,即配置文件的同一目录下,所以我们通常把私钥和配置文件放置到同一目录下,而不设置单独的参数来指定私钥文件。 +Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. -## 账号管理 +## Account Management -对于 TestNet 环境,我们提供了一个公用的测试账号私钥及配置文件用于快速接入测试,详情请参见 [CovenantSQL TestNet](quickstart) 快速上手教程。另外你也可以选择参照如下教程在本地创建新账号。 +For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. -### 创建新账号 +### Creating New Account -子命令 `generate` 在指定目录生成私钥及指向 TestNet 的配置文件,示例: +The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: ```bash cql generate config ``` -> 目前默认生成的配置文件指向测试网,还需要提供生成指向 Docker 一键部署网络的配置方法。 +> Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. -指定目录的参数详见[完整参数说明](#子命令-generate-完整参数)。 +For a complete help message, check [Complete Parameters](#sub-command-generate-complete-parameters). -输出: +Output: -```bash -Generating key pair... -Enter master key(press Enter for default: ""): - -Private key file: ~/.cql/private.key -Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 -Generated key pair. -Generating nonce... -INFO[0075] cpu: 4 -INFO[0075] position: 3, shift: 0x0, i: 3 -INFO[0075] position: 1, shift: 0x0, i: 1 -INFO[0075] position: 0, shift: 0x0, i: 0 -INFO[0075] position: 2, shift: 0x0, i: 2 -nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} -node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 -Generated nonce. -Generating config file... -Generated nonce. -``` + Generating key pair... + Enter master key(press Enter for default: ""): + + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + -### 获取私钥文件的公钥 +### Acquiring the Public Key -子命令 `generate` 也可以用来获取已经存在的私钥文件对应的公钥十六进制串。示例: +The sub-command `generate` is also used to acquire the public key (in hex string format) of the private key file, e.g.: ```bash cql generate public ``` -输出: +Output: -```bash -Enter master key(press Enter for default: ""): - -INFO[0011] init config success path=/home/levente/.cql/private.key -INFO[0011] use public key in config file: /home/levente/.cql/config.yaml -Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 -``` + Enter master key(press Enter for default: ""): + + INFO[0011] init config success path=/home/levente/.cql/private.key + INFO[0011] use public key in config file: /home/levente/.cql/config.yaml + Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 + -> 这一功能实际使用过程中暂时不会用到 +> This functionality is usually not used in common scene -### 子命令 `generate` 完整参数 +### Sub-command `generate` Complete Parameters -通用参数部分参考 [子命令通用参数](#子命令通用参数),以下介绍其他子命令时不再另外说明。 +Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this in the further sub-command introductions. -特殊地,在使用 `cql generate config` 命令生成新账号配置时,`-config`、`-no-password` 和 `-password` 等参数实际作用于将要生成的新私钥和配置文件,而不是要读取的文件。 + usage: cql generate [parameters]... config | public + + Generate command can generate private.key and config.yaml for CovenantSQL. + e.g. + cql generate config + + Params: + + -```bash -usage: cql generate [参数]... config | public +### Mine a Node ID -生成新私钥及配置文件,或获取指定配置的私钥文件对应的公钥。 - -Params: - 没有额外参数 -``` - -### 计算 Node ID - -子命令 `idminer` 用于计算指定配置文件(对应的私钥)的 Node ID(Node ID 的相关知识请参考[链接](terms#Node-ID))。示例: +The sub-command `idminer` is used to mine another Node ID of a private key (specified by a config file), (also check [Node ID](terms#Node-ID) for details). e.g.: ```bash cql idminer ``` -输出: - -```bash -INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 -Enter master key(press Enter for default: ""): - -INFO[0008] init config success path=/home/levente/.cql/config.yaml -INFO[0008] use public key in config file: /home/levente/.cql/config.yaml -INFO[0008] cpu: 8 -INFO[0008] position: 3, shift: 0x20, i: 7 -INFO[0008] position: 0, shift: 0x0, i: 0 -INFO[0008] position: 3, shift: 0x0, i: 6 -INFO[0008] position: 1, shift: 0x0, i: 2 -INFO[0008] position: 2, shift: 0x0, i: 4 -INFO[0008] position: 1, shift: 0x20, i: 3 -INFO[0008] position: 2, shift: 0x20, i: 5 -INFO[0008] position: 0, shift: 0x20, i: 1 -nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} -node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e -``` - -> 这一功能实际使用过程中暂时不会用到 - -### 子命令 `idminer` 完整参数 - -```bash -usage: cql idminer [-config file] [-difficulty number] [-loop false] - -为指定配置的私钥文件计算新的 Node ID。 - -Params: - -difficulty int - 生成 Node ID 的难度要求,默认值为 24 - -loop - 循环计算以取得更高难度的 Node ID -``` - -## 钱包管理 - -### 查看钱包地址 - -在配置好账号以后,可以通过 `wallet` 子命令来获取账号的钱包地址: +Output: + + INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 + Enter master key(press Enter for default: ""): + + INFO[0008] init config success path=/home/levente/.cql/config.yaml + INFO[0008] use public key in config file: /home/levente/.cql/config.yaml + INFO[0008] cpu: 8 + INFO[0008] position: 3, shift: 0x20, i: 7 + INFO[0008] position: 0, shift: 0x0, i: 0 + INFO[0008] position: 3, shift: 0x0, i: 6 + INFO[0008] position: 1, shift: 0x0, i: 2 + INFO[0008] position: 2, shift: 0x0, i: 4 + INFO[0008] position: 1, shift: 0x20, i: 3 + INFO[0008] position: 2, shift: 0x20, i: 5 + INFO[0008] position: 0, shift: 0x20, i: 1 + nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} + node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e + + +> This functionality is usually not used in common scene + +### Sub-command `idminer` Complete Parameters + + usage: cql idminer [parameter]... + + IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + e.g. + cql idminer -difficulty 24 + + If you want to mine a good id, use: + cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 + + Params: + -difficulty int + the difficulty for a miner to mine nodes and generating a nonce (default 24) + -loop + mining endless loop + + +## Wallet Management + +### Wallet Address + +Once the private key and config file is set, we can use sub-command `wallet` to check the wallet address of the account: ```bash cql wallet ``` -输出: +Output: -```bash -Enter master key(press Enter for default: ""): + Enter master key(press Enter for default: ""): + + wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 + -wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -``` - -这里可以看到我们用于测试的账号私钥文件对应的钱包地址是 `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`。 +The wallet address of the test account here is `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`. -### 查看钱包余额 +### Wallet Balances -获得钱包地址之后,就可以使用 `wallet` 子命令来查看你的钱包余额了。目前 CovenantSQL 支持的代币类型为以下 5 种: +We can also use sub-command `wallet` to check the balances in the wallet. CovenantSQL currently supports 5 types of tokens: - `Particle` - `Wave` @@ -181,182 +179,178 @@ wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 - `Ether` - `EOS` -其中 `Particle` 和 `Wave` 为 CovenantSQL 默认使用的代币,查看默认代币余额的命令为: +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. To check the token balances, use: ```bash cql wallet -balance all ``` -输出: +Output: -```bash -INFO[0000] Particle balance is: 10000000000000000000 -INFO[0000] Wave balance is: 10000000000000000000 -``` + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + -也可以单独指定代币类型,如查看 `Bitcoin` 余额: +You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: ```bash cql wallet -balance Bitcoin ``` -输出: +Output: -```bash -INFO[0000] Bitcoin balance is: 0 -``` + INFO[0000] Bitcoin balance is: 0 + -### 向其他账号转账 +### Transferring Tokens to Another Account -从 [TestNet](quickstart) 获得代币或 [Docker 一键部署](deployment)的网络获得代币后,可以使用 `transfer` 命令来向其他账号转账。转账操作使用 `json` 格式的转账信息作为参数,例如: +Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: ```json { - "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 收款地址 - "amount": "1000000 Particle" // 转账金额并带上单位 + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Receiver wallet address + "amount": "1000000 Particle" // Transfer amount with token type } ``` -其中收款地址可以是一个个人钱包地址也可以是一个数据库子链地址。转账至数据库地址时将在该数据库账户上补充付款人的押金与预付款。 - -把以上参数传给 `transfer` 子命令来进行转账: +Note that the receiver wallet address could be a user account address or a database address -- we treat the database as a special kind of account. While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. -```bash -cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' -``` +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). -输出: +Pass the parameter to `transfer`: ```bash -INFO[0000] succeed in sending transaction to CovenantSQL +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' ``` -注意,以上输出信息只说明交易请求已经成功发送至 CovenantSQL 网络,需要等待 BP 节点执行并确认交易后才能实际生效。交易能否成功、何时成功可以通过执行 `cql wallet -balance ` 来确定,也可以在执行命令时添加 `-wait-tx-confirm` 参数来让 `cql` 命令查询到执行结果之后再退出。 - -### 子命令 `wallet` 完整参数 +Output: -```bash -usage: cql wallet [-config file] [-balance token_type] + INFO[0000] succeed in sending transaction to CovenantSQL + -查看账号钱包地址和代币余额。 -示例: - cql wallet - cql wallet -balance Particle - cql wallet -balance all +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -balance ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. -Params: - -balance string - 获取当前账号中指定代币类型的余额 -``` - -### 子命令 `transfer` 完整参数 - -```bash -usage: cql transfer [-config file] [-wait-tx-confirm] meta_json +### Sub-command `wallet` Complete Parameters -向目标账号地址进行转账。输入参数为 JSON 格式的转账交易数据。 -示例: - cql transfer '{"addr": "your_account_addr", "amount": "100 Particle"}' + usage: cql wallet [-config file] [-balance token_name] + + Wallet command can get CovenantSQL wallet address and the token balance of the current account + e.g. + cql wallet + + cql wallet -balance Particle + cql wallet -balance all + + Params: + -balance string + Get a specific token's balance of the current account, e.g. Particle, Wave, and etc. + -由于 CovenantSQL 是区块链上的数据库,在交易生效之前你可能需要等待执行确认。 -示例: - cql transfer -wait-tx-confirm '{"addr": "your_account_addr", "amount": "100 Particle"}' +### Sub-command `transfer` Complete Parameters -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` + usage: cql transfer [-config file] [-wait-tx-confirm] meta_json + + Transfer command can transfer your token to the target account. + The command argument is JSON meta info of a token transaction. + e.g. + cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + + Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + e.g. + cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + -## 数据库管理 +## Database Management -### 创建数据库 +### Creating Database -创建数据库与 `transfer` 子命令类似使用 `json` 格式的输入参数,创建由一个节点组成的数据库: +Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: ```bash cql create '{"node": 1}' ``` -输出: - -```bash -Enter master key(press Enter for default: ""): +Output: -covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 -``` + Enter master key(press Enter for default: ""): + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + -注意这里生成的 `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 即为数据库的连接字符串(dsn),其中 `covenantsql` 为数据库协议字段,一般也可以缩写为 `cql`;`//` 后的十六进制串为数据库地址,可以在 `transfer` 子命令中作为收款地址使用。 +Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. -子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 +The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. -关于子命令 `create` 输入参数的完整说明,请参见[完整参数](#子命令-create-完整参数)。 +For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). -### ~~删除数据库~~ +### ~~Deleting Database~~ -~~未实现。~~ +~~Not yet implemented.~~ -### 数据库权限管理 +### Granting Permission -#### 访问权限 +#### Access Permission -CovenantSQL 数据库有三类库级别权限: +CovenantSQL database has 3 kinds of access permission: - `Admin` - `Write` - `Read` -- `Void` +- `Void` (for none) -其中,`Admin` 可以赋予其他钱包地址数据库的权限(`Admin`、`Write` 或 `Read`);`Admin` 和 `Write` 可以对数据库进行写操作(`CREATE`, `INSERT` 等);`Admin` 和 `Read` 可以对数据库进行读操作(`SHOW`, `SELECT` 等);如果需要设置用户有读写权限但是不能修改其他用户或自己的权限,可以将权限设置为 `Read,Write`;`Void` 是一个特殊的权限,当 `Admin` 想取消某个地址的权限时可以将该地址的权限设置为 `Void`,这样该地址将无法继续读写数据库。创建数据库的地址的权限默认为 `Admin`。 +Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. -假设我们用默认账号创建好了数据库 `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5`,在目录 `account2` 下创建好新账号配置,账号地址为 `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`,现在用默认账号给新账号授权已经创建好的数据库的访问权限,同样使用 `json` 格式的授权信息为参数: +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following: ```json { - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // 需要进行权限变更的数据库地址 - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // 需要赋予权限的钱包地址 - "perm": "Read,Write" // 权限内容,多个权限用英文逗号隔开 + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission + "perm": "Read,Write" // Permission, separated by commas } ``` -把以上参数传给 `grant` 子命令来增加读写权限: +Pass the parameter to `grant`: ```bash cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' ``` -输出: +Output: -```bash -INFO[0000] succeed in sending transaction to CovenantSQL -``` + INFO[0000] succeed in sending transaction to CovenantSQL + -吊销权限: +Or revoke the permission: ```bash cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' ``` -输出: +Output: -```bash -INFO[0000] succeed in sending transaction to CovenantSQL -``` + INFO[0000] succeed in sending transaction to CovenantSQL + -子命令 `grant` 通过向 BP 发起交易实现,所以也支持 `wait-tx-confirm` 参数。 +The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. -由于目前每个数据库实例分别为每个用户独立计费,所以为数据库添加新的账户权限后,需要以新账户身份向该数据库转押金与预付款才能进行正常查询。押金与预付款最小值的计算公式:`gas_price*number_of_miner*120000`。 +Since the database separately keeps billing for each user, you need to transfer tokens to the database (as user deposit and advance payment) from the new account before it can actually get access to the database. The minimum amount of deposit and advance payment can be calculated by: `gas_price*number_of_miner*120000`. -使用新账户给数据库充值: +Transferring from `account2` to the database: ```bash cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' ``` -#### SQL 白名单 +#### SQL White List -CovenantSQL 还支持给用户设置可执行的 SQL 白名单,可以限定用户以指定的 SQL Pattern 和可配的 Query 参数来访问数据库。在指定语句白名单的功能支持下,可以提高数据库的安全性,避免被单语句拖库或执行不正确的删除或更新操作。 +CovenantSQL supports white list setting for each of its users. By setting up SQL white list, you can further limit the access permission of a user to a given list of SQL Patterns with assignable parameters. With this feature, your database can be further secured because it avoids important data breach and accidentally updating/deleting. -增加白名单: +Adding a white list: ```bash cql grant ' @@ -374,11 +368,9 @@ cql grant ' ' ``` -*白名单功能是基于数据库权限的一个扩展,且当前不支持增量的白名单更新,在设置白名单时需要写明所有授权该用户使用的语句,以及该用户对数据库的访问权限* - -设置完成后,用户将只能执行 `SELECT COUNT(1) FROM a` 或 `SELECT * FROM a WHERE id = ? LIMIT 1` 的语句(语句内容严格匹配,使用 `select COUNT(1) FROM a` 或 `SELECT COUNT(1) FROM a` 也不可以);其中 第二条语句支持用户提供一个参数,以支持查询不同记录的目的。最终可以实现限定用户访问 `表 a`,并一次只能查询 `表 a` 中的一条数据或查询 `表 a` 的总数据量。 +*SQL White List is an extension of the database permission system. It currently doesn't support incrementally updating, so you need to provide the complete permission information each time you use the `grant` sub-command* -去掉白名单限制: +Cleaning the white list: ```bash cql grant ' @@ -401,244 +393,232 @@ cql grant ' ' ``` -将 `pattern` 设置为 `nil` 或直接设置用户权限,都可以将用户的白名单限制去掉,设置回可以查询所有内容的读权限。 - -### 子命令 `create` 完整参数 - -```bash -usage: cql create [-config file] [-wait-tx-confirm] db_meta_json - -为当前账号创建数据库实例,输入参数为 JSON 格式的创建交易数据,其中节点数 node 为必带字段。 -示例: - cql create '{"node": 2}' - -完整的 db_meta_json 字段解释如下: - targetminers []string // 目标节点的账号地址 - node int // 目标节点数 - space int // 需要的硬盘空间,0 为任意 - memory int // 需要的内存空间,0 为任意 - loadavgpercpu float // 需要的 CPU 资源占用,0 为任意 - encryptionkey string // 落盘加密密钥 - useeventualconsistency bool // 各个数据库节点之间是否使用最终一致性同步 - consistencylevel float // 一致性级别,通过 node*consistencylevel 得到强同步的节点数 - isolationlevel int // 单个节点上的隔离级别,默认级别为线性级别 - -由于 CovenantSQL 是区块链上的数据库,在真正访问数据库之前你可能需要等待创建请求的执行确认以及在数据库节点上的实际创建。 -示例: - cql create -wait-tx-confirm '{"node": 2}' - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -### 子命令 `drop` 完整参数 - -```bash -usage: cql drop [-config file] [-wait-tx-confirm] dsn/dbid - -通过数据库的连接字符串或账号地址来删除数据库。 -示例: - cql drop the_dsn_of_your_database - -由于 CovenantSQL 是区块链上的数据库,在删除操作生效之前你可能需要等待删除请求的执行确认以及在数据库节点上的实际执行。 -示例: - cql drop -wait-tx-confirm the_dsn_of_your_database - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -### 子命令 `grant` 完整参数 - -```bash -usage: cql grant [-config file] [-wait-tx-confirm] permission_meta_json - -为指定账号进行数据库权限授权。 -示例: - cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - -由于 CovenantSQL 是区块链上的数据库,在授权操作生效之前你可能需要等待授权请求的执行确认以及在数据库节点上的实际更新。 -示例 - cql grant -wait-tx-confirm '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - -Params: - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` - -## 访问数据库 - -完成数据库的创建后,就可以使用 `console` 子命令来对数据库进行交互式的命令行访问了: +Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. + +### Sub-command `create` Complete Parameters + + usage: cql create [parameters]... db_meta_json + + Create CovenantSQL database by database meta info JSON string, meta info must include node count. + e.g. + cql create '{"node":2}' + + A complete introduction of db_meta_json fields: + targetminers []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + loadavgpercpu float // Minimum idle CPU requirement, 0 for none + encryptionkey string // Encryption key for persistence data + useeventualconsistency bool // Use eventual consistency to sync among miner nodes + consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency + isolationlevel int // Isolation level in a single node + + Since CovenantSQL is blockchain database, you may want get confirm of creation. + e.g. + cql create -wait-tx-confirm '{"node": 2}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +### Sub-command `drop` Complete Parameters + + usage: cql drop [parameter]... dsn/dbid + + Drop command can drop a database by DSN or database id + e.g. + cql drop covenantsql://the_dsn_of_your_database + + Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + e.g. + cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +### Sub-command `grant` Complete Parameters + + usage: cql grant [parameter]... permission_meta_json + + Grant command can give a user some specific permissions on your database + e.g. + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + + Since CovenantSQL is blockchain database, you may want get confirm of permission update. + e.g. + cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Accessing Database + +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: ```bash cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` -输出 - -```bash -Enter master key(press Enter for default: ""): +Output: -INFO[0010] init config success path=/home/levente/.cql/config.yaml -INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" -Connected with driver covenantsql (develop-34ae741a-20190416184528) -Type "help" for help. + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -或者使用以授权的账号来连接: +Or access as `account2` if it has successfully been granted access permission: ```bash cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` -输出 - -```bash -Enter master key(press Enter for default: ""): - -INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml -INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" -Connected with driver covenantsql (develop-34ae741a-20190416184528) -Type "help" for help. - -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -交互式访问示例: - -```bash -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); -CREATE TABLE -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); -INSERT -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; -c1 ----- -1 -2 -3 -(3 rows) - -co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -``` - -### 子命令 `console` 完整参数 - -子命令 `console` 同时也支持在后台启动 `adapter` 和 `explorer` 服务,关于这些服务的相关说明请参考 [本地服务](#本地服务) 的相关章节。 - -```bash -usage: cql console [-config file] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] - -为 CovenantSQL 运行交互式的命令行访问。 -示例: - cql console -dsn the_dsn_of_your_database - -另外也可以通过 -command 参数来直接运行 SQL 查询语句或通过 -file 参数来从文件读取查询语句。 -在指定了这些参数的情况下 `console` 子命令将会直接执行命令后退出,而不会进入交互式的命令行模式。 -示例: - cql console -dsn the_dsn_of_your_database -command "create table test1(test2 int);" - -Params: - -adapter string - 指定数据库子链的 adapter 服务器的监听地址 - -command string - 执行单条 SQL 语句并退出 - -dsn string - 数据库连接字符串 - -explorer string - 指定数据库子链的 explorer 服务器监听地址 - -file string - 执行 SQL 脚本中的语句并退出 - -no-rc - 启动时不加载 .rc 初始脚本 - -out string - 指定输出文件 - -single-transaction - 在非交互模式下使用单个事务执行所有语句 - -variable value - 设置环境变量 -``` - -## 本地服务 - -### 子命令 `explorer` 完整参数 - -```bash -usage: cql explorer [-config file] [-tmp-path path] [-bg-log-level level] address - -为数据库子链运行 adapter 服务器。 -示例: - cql explorer 127.0.0.1:8546 - -Params: - -bg-log-level string - 后台服务日志级别 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -### 子命令 `mirror` 完整参数 - -```bash -usage: cql mirror [-config file] [-tmp-path path] [-bg-log-level level] dsn/dbid address - -为数据库子链运行 mirror 服务器。 -示例: - cql mirror database_id 127.0.0.1:9389 - -Params: - -bg-log-level string - 后台服务日志级别 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -### 子命令 `adapter` 完整参数 - -关于 `adapter` 服务的说明请参考 。 - -```bash -usage: cql adapter [-config file] [-tmp-path path] [-bg-log-level level] [-mirror addr] address - -为数据库子链运行 adapter 服务器。 -示例: - cql adapter 127.0.0.1:7784 - -Params: - -bg-log-level string - 后台服务日志级别 - -mirror string - 指定镜像 adapter 服务器地址 - -tmp-path string - 后台服务使用的临时目录,默认使用系统的默认临时文件路径 -``` - -## 高级使用 - -子命令 `rpc` 直接在 CovenantSQL 网络上进行 RPC 调用。 - -### 子命令 `rpc` 完整参数 - -```bash -usage: cql rpc [-config file] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request - -向目标服务器发送 RPC 请求。 -示例: - cql rpc -name 'MCC.QuerySQLChainProfile' \ - -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ - -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' - -Params: - -endpoint string - 目标 RPC Node ID - -name string - 目标 RPC 服务.方法名 - -req string - RPC 请求数据,JSON 格式 - -wait-tx-confirm - 等待交易执行确认(或者出现任何错误)后再退出 -``` \ No newline at end of file +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +### Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [parameter]... + + Console command can run a interactive SQL console for CovenantSQL + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database + + There is also a -command param for SQL script, and a -file param for reading SQL in a file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + + Params: + -adapter string + Address to serve a database chain adapter, e.g.:7784 + -command string + Run only single command (SQL or usql internal command) and exit + -dsn string + Database url + -explorer string + Address to serve a database chain explorer, e.g.:8546 + -file string + Execute commands from file and exit + -no-rc + Do not read startup file + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable + + +## Local Servers + +### Sub-command `explorer` Complete Parameter + + usage: cql explorer [parameter]... address + + Explorer command serves a SQLChain web explorer. + e.g. + cql explorer 127.0.0.1:8546 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +### Sub-command `mirror` Complete Parameter + + usage: cql mirror [parameter]... dsn/dbid address + + Mirror command subscribes database updates and serves a read-only database mirror. + e.g. + cql mirror database_id 127.0.0.1:9389 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +### Sub-command `adapter` Complete Parameter + +See for details of adapter server. + + usage: cql adapter [parameter]... address + + Adapter command serves a SQLChain adapter + e.g. + cql adapter 127.0.0.1:7784 + + Params: + -bg-log-level string + Background service log level + -mirror string + mirror server for the target adapter to query + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Advance Usage + +Sub-command `rpc` calls the remote process directly in the CovenantSQL network. + +### Sub-command `rpc` Complete Parameter + + usage: cql rpc [parameter]... + + Rpc command make a RPC request to the target server + e.g. + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + + Params: + -endpoint string + RPC endpoint to do a test call + -name string + RPC name to do a test call + -req string + RPC request to do a test call, in json format + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From b2e3f1e1ac8cd39a7104a759eefd80ae282d8e70 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:33 +0800 Subject: [PATCH 207/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 118 +++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_account.md diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md new file mode 100644 index 0000000..3a5e373 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_account.md @@ -0,0 +1,118 @@ +--- +id: cql_account +title: Account Management +--- +For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. + +## Creating New Account + +The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: + +```bash +cql generate config +``` + +> Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. + +For a complete help message, check [Complete Parameters](#sub-command-generate-complete-parameters). + +Output: + + Generating key pair... + Enter master key(press Enter for default: ""): + + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +## Acquiring the Public Key + +The sub-command `generate` is also used to acquire the public key (in hex string format) of the private key file, e.g.: + +```bash +cql generate public +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0011] init config success path=/home/levente/.cql/private.key + INFO[0011] use public key in config file: /home/levente/.cql/config.yaml + Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 + + +> This functionality is usually not used in common scene. + +## Sub-command `generate` Complete Parameters + +Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. + + usage: cql generate [parameter]... config | public + + Generate command can generate private.key and config.yaml for CovenantSQL. + e.g. + cql generate config + + Params: + + + +## Mine a Node ID + +The sub-command `idminer` is used to mine another Node ID of a private key (specified by a config file), (also check [Node ID](terms#node-id) for details). e.g.: + +```bash +cql idminer +``` + +Output: + + INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 + Enter master key(press Enter for default: ""): + + INFO[0008] init config success path=/home/levente/.cql/config.yaml + INFO[0008] use public key in config file: /home/levente/.cql/config.yaml + INFO[0008] cpu: 8 + INFO[0008] position: 3, shift: 0x20, i: 7 + INFO[0008] position: 0, shift: 0x0, i: 0 + INFO[0008] position: 3, shift: 0x0, i: 6 + INFO[0008] position: 1, shift: 0x0, i: 2 + INFO[0008] position: 2, shift: 0x0, i: 4 + INFO[0008] position: 1, shift: 0x20, i: 3 + INFO[0008] position: 2, shift: 0x20, i: 5 + INFO[0008] position: 0, shift: 0x20, i: 1 + nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} + node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e + + +> This functionality is usually not used in common scene. + +## Sub-command `idminer` Complete Parameters + + usage: cql idminer [parameter]... + + IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + e.g. + cql idminer -difficulty 24 + + If you want to mine a good id, use: + cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 + + Params: + -difficulty int + the difficulty for a miner to mine nodes and generating a nonce (default 24) + -loop + mining endless loop \ No newline at end of file From 378e0721a3fd550b341b4ea5cffedc668f622fae Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:34 +0800 Subject: [PATCH 208/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_advance.md | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_advance.md diff --git a/website/translated_docs/zh-CN/cql_advance.md b/website/translated_docs/zh-CN/cql_advance.md new file mode 100644 index 0000000..6fdbc28 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_advance.md @@ -0,0 +1,25 @@ +--- +id: cql_advance +title: Advance Usage +--- +Sub-command `rpc` calls the remote process directly in the CovenantSQL network. + +## Sub-command `rpc` Complete Parameter + + usage: cql rpc [parameter]... + + Rpc command make a RPC request to the target server + e.g. + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + + Params: + -endpoint string + RPC endpoint to do a test call + -name string + RPC name to do a test call + -req string + RPC request to do a test call, in json format + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From df11e610857185a52cdcaa295d28e32eb697c5c3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:36 +0800 Subject: [PATCH 209/421] New translations cql_db_access.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_access.md | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_db_access.md diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md new file mode 100644 index 0000000..32f09d8 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -0,0 +1,91 @@ +--- +id: cql_db_access +title: Accessing Database +--- +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: + +```bash +cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Or access as `account2` if it has successfully been granted access permission: + +```bash +cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +## Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [parameter]... + + Console command can run a interactive SQL console for CovenantSQL + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database + + There is also a -command param for SQL script, and a -file param for reading SQL in a file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + + Params: + -adapter string + Address to serve a database chain adapter, e.g.:7784 + -command string + Run only single command (SQL or usql internal command) and exit + -dsn string + Database url + -explorer string + Address to serve a database chain explorer, e.g.:8546 + -file string + Execute commands from file and exit + -no-rc + Do not read startup file + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable \ No newline at end of file From 8f95cff4eb016062bd6e13bac4787304983021da Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:37 +0800 Subject: [PATCH 210/421] New translations cql_db_manage.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_manage.md | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_db_manage.md diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md new file mode 100644 index 0000000..f61a740 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -0,0 +1,193 @@ +--- +id: cql_db_manage +title: Database Management +--- +## Creating Database + +Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: + +```bash +cql create '{"node": 1}' +``` + +Output: + + Enter master key(press Enter for default: ""): + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. + +The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. + +For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). + +## ~~Deleting Database~~ + +~~Not yet implemented.~~ + +## Granting Permission + +### Access Permission + +CovenantSQL database has 3 kinds of access permission: + +- `Admin` +- `Write` +- `Read` +- `Void` (for none) + +Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. + +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following: + +```json +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission + "perm": "Read,Write" // Permission, separated by commas +} +``` + +Pass the parameter to `grant`: + +```bash +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +Or revoke the permission: + +```bash +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. + +Since the database separately keeps billing for each user, you need to transfer tokens to the database (as user deposit and advance payment) from the new account before it can actually get access to the database. The minimum amount of deposit and advance payment can be calculated by: `gas_price*number_of_miner*120000`. + +Transferring from `account2` to the database: + +```bash +cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' +``` + +### SQL White List + +CovenantSQL supports white list setting for each of its users. By setting up SQL white list, you can further limit the access permission of a user to a given list of SQL Patterns with assignable parameters. With this feature, your database can be further secured because it avoids important data breach and accidentally updating/deleting. + +Adding a white list: + +```bash +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read,Write" + } +} +' +``` + +*SQL White List is an extension of the database permission system. It currently doesn't support incrementally updating, so you need to provide the complete permission information each time you use the `grant` sub-command* + +Cleaning the white list: + +```bash +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read,Write" + } +} +' + or +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read,Write" +} +' +``` + +Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. + +## Sub-command `create` Complete Parameters + + usage: cql create [parameter]... db_meta_json + + Create CovenantSQL database by database meta info JSON string, meta info must include node count. + e.g. + cql create '{"node":2}' + + A complete introduction of db_meta_json fields: + targetminers []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + loadavgpercpu float // Minimum idle CPU requirement, 0 for none + encryptionkey string // Encryption key for persistence data + useeventualconsistency bool // Use eventual consistency to sync among miner nodes + consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency + isolationlevel int // Isolation level in a single node + + Since CovenantSQL is blockchain database, you may want get confirm of creation. + e.g. + cql create -wait-tx-confirm '{"node": 2}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `drop` Complete Parameters + + usage: cql drop [parameter]... dsn/dbid + + Drop command can drop a database by DSN or database id + e.g. + cql drop covenantsql://the_dsn_of_your_database + + Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + e.g. + cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `grant` Complete Parameters + + usage: cql grant [parameter]... permission_meta_json + + Grant command can give a user some specific permissions on your database + e.g. + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + + Since CovenantSQL is blockchain database, you may want get confirm of permission update. + e.g. + cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From f2b7dde8e074958d36e2521bde9570c1d7c54369 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:38 +0800 Subject: [PATCH 211/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_intro.md diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md new file mode 100644 index 0000000..d3e3353 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -0,0 +1,30 @@ +--- +id: cql_intro +title: Intro +--- +CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). + +## Private Key and Config File + +The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: + +- `private.key`:a private key file which is generated while creating an account, be sure to keep it safe +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) + +For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. + +## Common Parameters for Sub-commands + +The following parameters are commonly used by `cql` sub-commands: + + -bypass-signature + Disable signature signing and verifying, for testing only + -config string + Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") + -no-password + Use an empty master key + -password string + Master key for covenantsql (NOT SAFE, for debugging or script mode only) + + +Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. \ No newline at end of file From 940fcf035de022c7e71b1a6e8069e0b611358b1a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:39 +0800 Subject: [PATCH 212/421] New translations cql_server.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_server.md | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_server.md diff --git a/website/translated_docs/zh-CN/cql_server.md b/website/translated_docs/zh-CN/cql_server.md new file mode 100644 index 0000000..bdcf019 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_server.md @@ -0,0 +1,51 @@ +--- +id: cql_server +title: Local Servers +--- +## Sub-command `explorer` Complete Parameter + + usage: cql explorer [parameter]... address + + Explorer command serves a SQLChain web explorer. + e.g. + cql explorer 127.0.0.1:8546 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Sub-command `mirror` Complete Parameter + + usage: cql mirror [parameter]... dsn/dbid address + + Mirror command subscribes database updates and serves a read-only database mirror. + e.g. + cql mirror database_id 127.0.0.1:9389 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Sub-command `adapter` Complete Parameter + +See for details of adapter server. + + usage: cql adapter [parameter]... address + + Adapter command serves a SQLChain adapter + e.g. + cql adapter 127.0.0.1:7784 + + Params: + -bg-log-level string + Background service log level + -mirror string + mirror server for the target adapter to query + -tmp-path string + Background service temp file path, use os.TempDir for default \ No newline at end of file From f46a9a7f397df3b6c2e5490aca3ce18a85d2d72e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:40 +0800 Subject: [PATCH 213/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 114 ++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 website/translated_docs/zh-CN/cql_wallet.md diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md new file mode 100644 index 0000000..ead0b10 --- /dev/null +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -0,0 +1,114 @@ +--- +id: cql_wallet +title: Wallet Management +--- +## Wallet Address + +Once the private key and config file is set, you can use sub-command `wallet` to check the wallet address of the account: + +```bash +cql wallet +``` + +Output: + + Enter master key(press Enter for default: ""): + + wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 + + +The wallet address of the test account here is `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`. + +## Wallet Balances + +We can also use sub-command `wallet` to check the balances in the wallet. CovenantSQL currently supports 5 types of tokens: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. To check the token balances, use: + +```bash +cql wallet -balance all +``` + +Output: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: + +```bash +cql wallet -balance Bitcoin +``` + +Output: + + INFO[0000] Bitcoin balance is: 0 + + +## Transferring Tokens to Another Account + +Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: + +```json +{ + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Receiver wallet address + "amount": "1000000 Particle" // Transfer amount with token type +} +``` + +Note that the receiver wallet address could be a user account address or a database address -- we treat the database as a special kind of account. While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. + +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). + +Pass the parameter to `transfer`: + +```bash +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -balance ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. + +## Sub-command `wallet` Complete Parameters + + usage: cql wallet [parameter]... + + Wallet command can get CovenantSQL wallet address and the token balance of the current account + e.g. + cql wallet + + cql wallet -balance Particle + cql wallet -balance all + + Params: + -balance string + Get a specific token's balance of the current account, e.g. Particle, Wave, and etc. + + +## Sub-command `transfer` Complete Parameters + + usage: cql transfer [parameter]... meta_json + + Transfer command can transfer your token to the target account. + The command argument is JSON meta info of a token transaction. + e.g. + cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + + Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + e.g. + cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From 912ca95fc61432d80ac65da8badf76862999dd74 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:42 +0800 Subject: [PATCH 214/421] New translations cql_account.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_account.md | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_account.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_account.md b/website/translated_docs/zh-CN/version-0.5.0/cql_account.md new file mode 100644 index 0000000..2883c9c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_account.md @@ -0,0 +1,119 @@ +--- +id: version-0.5.0-cql_account +title: Account Management +original_id: cql_account +--- +For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. + +## Creating New Account + +The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: + +```bash +cql generate config +``` + +> Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. + +For a complete help message, check [Complete Parameters](#sub-command-generate-complete-parameters). + +Output: + + Generating key pair... + Enter master key(press Enter for default: ""): + + Private key file: ~/.cql/private.key + Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 + Generated key pair. + Generating nonce... + INFO[0075] cpu: 4 + INFO[0075] position: 3, shift: 0x0, i: 3 + INFO[0075] position: 1, shift: 0x0, i: 1 + INFO[0075] position: 0, shift: 0x0, i: 0 + INFO[0075] position: 2, shift: 0x0, i: 2 + nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} + node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + Generated nonce. + Generating config file... + Generated nonce. + + +## Acquiring the Public Key + +The sub-command `generate` is also used to acquire the public key (in hex string format) of the private key file, e.g.: + +```bash +cql generate public +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0011] init config success path=/home/levente/.cql/private.key + INFO[0011] use public key in config file: /home/levente/.cql/config.yaml + Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 + + +> This functionality is usually not used in common scene. + +## Sub-command `generate` Complete Parameters + +Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. + + usage: cql generate [parameter]... config | public + + Generate command can generate private.key and config.yaml for CovenantSQL. + e.g. + cql generate config + + Params: + + + +## Mine a Node ID + +The sub-command `idminer` is used to mine another Node ID of a private key (specified by a config file), (also check [Node ID](terms#node-id) for details). e.g.: + +```bash +cql idminer +``` + +Output: + + INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 + Enter master key(press Enter for default: ""): + + INFO[0008] init config success path=/home/levente/.cql/config.yaml + INFO[0008] use public key in config file: /home/levente/.cql/config.yaml + INFO[0008] cpu: 8 + INFO[0008] position: 3, shift: 0x20, i: 7 + INFO[0008] position: 0, shift: 0x0, i: 0 + INFO[0008] position: 3, shift: 0x0, i: 6 + INFO[0008] position: 1, shift: 0x0, i: 2 + INFO[0008] position: 2, shift: 0x0, i: 4 + INFO[0008] position: 1, shift: 0x20, i: 3 + INFO[0008] position: 2, shift: 0x20, i: 5 + INFO[0008] position: 0, shift: 0x20, i: 1 + nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} + node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e + + +> This functionality is usually not used in common scene. + +## Sub-command `idminer` Complete Parameters + + usage: cql idminer [parameter]... + + IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + e.g. + cql idminer -difficulty 24 + + If you want to mine a good id, use: + cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 + + Params: + -difficulty int + the difficulty for a miner to mine nodes and generating a nonce (default 24) + -loop + mining endless loop \ No newline at end of file From 9757e16f04556f35ad37ed80372fe3d551566390 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:43 +0800 Subject: [PATCH 215/421] New translations cql_advance.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_advance.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_advance.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md new file mode 100644 index 0000000..8bf3cd2 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md @@ -0,0 +1,26 @@ +--- +id: version-0.5.0-cql_advance +title: Advance Usage +original_id: cql_advance +--- +Sub-command `rpc` calls the remote process directly in the CovenantSQL network. + +## Sub-command `rpc` Complete Parameter + + usage: cql rpc [parameter]... + + Rpc command make a RPC request to the target server + e.g. + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + + Params: + -endpoint string + RPC endpoint to do a test call + -name string + RPC name to do a test call + -req string + RPC request to do a test call, in json format + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From f24d9af8a3a1518b43bfe64c6dc152cf13f6b899 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:44 +0800 Subject: [PATCH 216/421] New translations cql_db_access.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_db_access.md | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md b/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md new file mode 100644 index 0000000..5d4a471 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md @@ -0,0 +1,92 @@ +--- +id: version-0.5.0-cql_db_access +title: Accessing Database +original_id: cql_db_access +--- +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: + +```bash +cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Or access as `account2` if it has successfully been granted access permission: + +```bash +cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + Enter master key(press Enter for default: ""): + + INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-34ae741a-20190416184528) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +## Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [parameter]... + + Console command can run a interactive SQL console for CovenantSQL + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database + + There is also a -command param for SQL script, and a -file param for reading SQL in a file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + + Params: + -adapter string + Address to serve a database chain adapter, e.g.:7784 + -command string + Run only single command (SQL or usql internal command) and exit + -dsn string + Database url + -explorer string + Address to serve a database chain explorer, e.g.:8546 + -file string + Execute commands from file and exit + -no-rc + Do not read startup file + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable \ No newline at end of file From d4e03f8527f22629ebfd8d5f64bab27a8df3d56e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:45 +0800 Subject: [PATCH 217/421] New translations cql_db_manage.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_db_manage.md | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md new file mode 100644 index 0000000..b4bc0f8 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md @@ -0,0 +1,194 @@ +--- +id: version-0.5.0-cql_db_manage +title: Database Management +original_id: cql_db_manage +--- +## Creating Database + +Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: + +```bash +cql create '{"node": 1}' +``` + +Output: + + Enter master key(press Enter for default: ""): + + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + + +Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. + +The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. + +For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). + +## ~~Deleting Database~~ + +~~Not yet implemented.~~ + +## Granting Permission + +### Access Permission + +CovenantSQL database has 3 kinds of access permission: + +- `Admin` +- `Write` +- `Read` +- `Void` (for none) + +Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. + +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following: + +```json +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission + "perm": "Read,Write" // Permission, separated by commas +} +``` + +Pass the parameter to `grant`: + +```bash +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +Or revoke the permission: + +```bash +cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. + +Since the database separately keeps billing for each user, you need to transfer tokens to the database (as user deposit and advance payment) from the new account before it can actually get access to the database. The minimum amount of deposit and advance payment can be calculated by: `gas_price*number_of_miner*120000`. + +Transferring from `account2` to the database: + +```bash +cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' +``` + +### SQL White List + +CovenantSQL supports white list setting for each of its users. By setting up SQL white list, you can further limit the access permission of a user to a given list of SQL Patterns with assignable parameters. With this feature, your database can be further secured because it avoids important data breach and accidentally updating/deleting. + +Adding a white list: + +```bash +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read,Write" + } +} +' +``` + +*SQL White List is an extension of the database permission system. It currently doesn't support incrementally updating, so you need to provide the complete permission information each time you use the `grant` sub-command* + +Cleaning the white list: + +```bash +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": { + "patterns": nil, + "role": "Read,Write" + } +} +' + or +cql grant ' +{ + "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", + "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", + "perm": "Read,Write" +} +' +``` + +Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. + +## Sub-command `create` Complete Parameters + + usage: cql create [parameter]... db_meta_json + + Create CovenantSQL database by database meta info JSON string, meta info must include node count. + e.g. + cql create '{"node":2}' + + A complete introduction of db_meta_json fields: + targetminers []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + loadavgpercpu float // Minimum idle CPU requirement, 0 for none + encryptionkey string // Encryption key for persistence data + useeventualconsistency bool // Use eventual consistency to sync among miner nodes + consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency + isolationlevel int // Isolation level in a single node + + Since CovenantSQL is blockchain database, you may want get confirm of creation. + e.g. + cql create -wait-tx-confirm '{"node": 2}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `drop` Complete Parameters + + usage: cql drop [parameter]... dsn/dbid + + Drop command can drop a database by DSN or database id + e.g. + cql drop covenantsql://the_dsn_of_your_database + + Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + e.g. + cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + + Params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `grant` Complete Parameters + + usage: cql grant [parameter]... permission_meta_json + + Grant command can give a user some specific permissions on your database + e.g. + cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + + Since CovenantSQL is blockchain database, you may want get confirm of permission update. + e.g. + cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From e639beab968a0441037595917df4bfc65718ca3e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:46 +0800 Subject: [PATCH 218/421] New translations cql_intro.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_intro.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_intro.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md new file mode 100644 index 0000000..93311be --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md @@ -0,0 +1,31 @@ +--- +id: version-0.5.0-cql_intro +title: Intro +original_id: cql_intro +--- +CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). + +## Private Key and Config File + +The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: + +- `private.key`:a private key file which is generated while creating an account, be sure to keep it safe +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) + +For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. + +## Common Parameters for Sub-commands + +The following parameters are commonly used by `cql` sub-commands: + + -bypass-signature + Disable signature signing and verifying, for testing only + -config string + Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") + -no-password + Use an empty master key + -password string + Master key for covenantsql (NOT SAFE, for debugging or script mode only) + + +Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. \ No newline at end of file From 18ca5436ca57039618307899dfdbc8fc32d742dc Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:47 +0800 Subject: [PATCH 219/421] New translations cql_server.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_server.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_server.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_server.md b/website/translated_docs/zh-CN/version-0.5.0/cql_server.md new file mode 100644 index 0000000..b4d1546 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_server.md @@ -0,0 +1,52 @@ +--- +id: version-0.5.0-cql_server +title: Local Servers +original_id: cql_server +--- +## Sub-command `explorer` Complete Parameter + + usage: cql explorer [parameter]... address + + Explorer command serves a SQLChain web explorer. + e.g. + cql explorer 127.0.0.1:8546 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Sub-command `mirror` Complete Parameter + + usage: cql mirror [parameter]... dsn/dbid address + + Mirror command subscribes database updates and serves a read-only database mirror. + e.g. + cql mirror database_id 127.0.0.1:9389 + + Params: + -bg-log-level string + Background service log level + -tmp-path string + Background service temp file path, use os.TempDir for default + + +## Sub-command `adapter` Complete Parameter + +See for details of adapter server. + + usage: cql adapter [parameter]... address + + Adapter command serves a SQLChain adapter + e.g. + cql adapter 127.0.0.1:7784 + + Params: + -bg-log-level string + Background service log level + -mirror string + mirror server for the target adapter to query + -tmp-path string + Background service temp file path, use os.TempDir for default \ No newline at end of file From 7f70ed0b1f761ee90923948452defb792177dc28 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 12:05:48 +0800 Subject: [PATCH 220/421] New translations cql_wallet.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_wallet.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md b/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md new file mode 100644 index 0000000..51f986c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md @@ -0,0 +1,115 @@ +--- +id: version-0.5.0-cql_wallet +title: Wallet Management +original_id: cql_wallet +--- +## Wallet Address + +Once the private key and config file is set, you can use sub-command `wallet` to check the wallet address of the account: + +```bash +cql wallet +``` + +Output: + + Enter master key(press Enter for default: ""): + + wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 + + +The wallet address of the test account here is `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`. + +## Wallet Balances + +We can also use sub-command `wallet` to check the balances in the wallet. CovenantSQL currently supports 5 types of tokens: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. To check the token balances, use: + +```bash +cql wallet -balance all +``` + +Output: + + INFO[0000] Particle balance is: 10000000000000000000 + INFO[0000] Wave balance is: 10000000000000000000 + + +You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: + +```bash +cql wallet -balance Bitcoin +``` + +Output: + + INFO[0000] Bitcoin balance is: 0 + + +## Transferring Tokens to Another Account + +Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: + +```json +{ + "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Receiver wallet address + "amount": "1000000 Particle" // Transfer amount with token type +} +``` + +Note that the receiver wallet address could be a user account address or a database address -- we treat the database as a special kind of account. While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. + +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). + +Pass the parameter to `transfer`: + +```bash +cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' +``` + +Output: + + INFO[0000] succeed in sending transaction to CovenantSQL + + +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -balance ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. + +## Sub-command `wallet` Complete Parameters + + usage: cql wallet [parameter]... + + Wallet command can get CovenantSQL wallet address and the token balance of the current account + e.g. + cql wallet + + cql wallet -balance Particle + cql wallet -balance all + + Params: + -balance string + Get a specific token's balance of the current account, e.g. Particle, Wave, and etc. + + +## Sub-command `transfer` Complete Parameters + + usage: cql transfer [parameter]... meta_json + + Transfer command can transfer your token to the target account. + The command argument is JSON meta info of a token transaction. + e.g. + cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + + Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + e.g. + cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + + Params: + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From 77a9764895fcc1ca081e8df33eae598df25bf0c5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:46:46 +0800 Subject: [PATCH 221/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 93d6f8d..179e060 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -13,7 +13,7 @@ title: Quick Start - 🍺 Homebrew 用户可以直接在命令行: ```bash -brew tap CovenantSQL/cql && brew install cql +brew install cql ``` - 非 Homebrew,可以执行: From 233a27e55cfea2bb932f7aa547f9bac38a676189 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:46:56 +0800 Subject: [PATCH 222/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index d3a34ba..9a58bf1 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -14,7 +14,7 @@ original_id: quickstart - 🍺 Homebrew 用户可以直接在命令行: ```bash -brew tap CovenantSQL/cql && brew install cql +brew install cql ``` - 非 Homebrew,可以执行: From f140bd0fe55c56d97b7efde667d9b324f8b0f3f7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:59:19 +0800 Subject: [PATCH 223/421] New translations arch.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch.md | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 website/translated_docs/zh-CN/arch.md diff --git a/website/translated_docs/zh-CN/arch.md b/website/translated_docs/zh-CN/arch.md new file mode 100644 index 0000000..5611d55 --- /dev/null +++ b/website/translated_docs/zh-CN/arch.md @@ -0,0 +1,58 @@ +--- +id: arch +title: Architecture +--- +## 3 Layers Arch + +![CovenantSQL 3 Layer design](https://github.com/CovenantSQL/CovenantSQL/raw/ed2878359345cd86e4221f14cd59e4654361b64e/logo/arch.png) + +- Layer 1: **Global Consensus Layer** (the main chain, the middle ring in the architecture diagram): + - There will only be one main chain throughout the network. + - Mainly responsible for database Miner and the user’s contract matching, transaction settlement, anti-cheating, shard chain lock hash and other global consensus matters. +- Layer 2: **SQL Consensus Layer** (shard chain, rings on both sides): + - Each database will have its own separate shard chain. + - Mainly responsible for: the signature, delivery and consistency of the various Transactions of the database. The data history of the permanent traceability is mainly implemented here, and the hash lock is performed in the main chain. +- Layer 3: **Datastore Layer** (database engine with SQL-92 support): + - Each Database has its own independent distributed engine. + - Mainly responsible for: database storage & encryption, query processing & signature, efficient indexing. + +## Consensus Algorithm + +CQL supports 2 kinds of consensus algorithm: + +1. DPoS (Delegated Proof-of-Stake) is applied in `Eventually consistency mode` database and also `Layer 1 (Global Consensus Layer)` in BlockProducer. CQL miners pack all SQL queries and its signatures by the client into blocks thus form a blockchain. We named the algorithm [`Xenomint`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/xenomint). +2. BFT-Raft (Byzantine Fault-Toleranted Raft)bft-raft is applied in `Strong consistency mode` database. We named our implementation [`Kayak`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/kayak). The CQL miner leader does a `Two-Phase Commit` with `Kayak` to support `Transaction`.transaction + +CQL database consistency mode and node count can be selected in database creation with command `cql create '{"UseEventualConsistency": true, "Node": 3}'` + +## Comparison + +| | Ethereum | Hyperledger Fabric | Amazon QLDB | CovenantSQL | +| ---------------------------- | ----------------- | ---------------------- | ----------- | -------------------------------------------------------------------- | +| **Dev language** | Solidity, ewasm | Chaincode (Go, NodeJS) | ? | Python, Golang, Java, PHP, NodeJS, MatLab | +| **Dev Pattern** | Smart Contract | Chaincode | SQL | SQL | +| **Open Source** | Y | Y | N | Y | +| **Nodes for HA** | 3 | 15 | ? | 3 | +| **Column Level ACL** | N | Y | ? | Y | +| **Data Format** | File | Key-value | Document | Filefuse, Key-value, Structured | +| **Storage Encryption** | N | API | Y | Y | +| **Data Desensitization** | N | N | N | Y | +| **Multi-tenant** | DIY | DIY | N | Y | +| **Throughput (1s delay)** | 15~10 tx/s | 3500 tx/s | ? | 11065 tx/s (Eventually Consistency) +1866 tx/s (Strong Consistency) | +| **Consistency Delay** | 2~6 min | < 1 s | ? | < 10 ms | +| **Secure for Open Internet** | Y | N | Only in AWS | Y | +| **Consensus** | PoW + PoS(Casper) | CFT | ? | DPoS (Eventually Consistency) +BFT-Raft (Strong Consistency) | + +### FootNotes + +- BFT-Raft: A CQL leader offline needs CQL Block Producer to decide whether to wait for leader online for data integrity or promote a follower node for availability. This part is still under construction and any advice is welcome. + +- Transaction: Talking about `ACID`, CQL has full "Consistency, Isolation, Durability" and a limited `Atomicity` support. That is even under strong consistency mode, CQL transaction is only supported on the leader node. If you want to do "read `v`, `v++`, write `v` back" parallelly and atomically, then the only way is "read `v` from the leader, `v++`, write `v` back to leader" + +- FUSE: CQL has a [simple FUSE](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql-fuse) support adopted from CockroachDB. The performance is not very ideal and still has some issues. But it can pass fio test like: + + ```bash + fio --debug=io --loops=1 --size=8m --filename=../mnt/fiotest.tmp --stonewall --direct=1 --name=Seqread --bs=128k --rw=read --name=Seqwrite --bs=128k --rw=write --name=4krandread --bs=4k --rw=randread --name=4krandwrite --bs=4k --rw=randwrite + ``` \ No newline at end of file From a7e4276ebd35f6fbb80b17982f137cf9d4cb3db4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:59:22 +0800 Subject: [PATCH 224/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/intro.md | 47 ++++++++------------------ 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/website/translated_docs/zh-CN/intro.md b/website/translated_docs/zh-CN/intro.md index bcdec0e..4164d24 100644 --- a/website/translated_docs/zh-CN/intro.md +++ b/website/translated_docs/zh-CN/intro.md @@ -32,41 +32,24 @@ title: CovenantSQL Intro alt="Join the chat at https://gitter.im/CovenantSQL/CovenantSQL">

-CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, +CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: -结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 +- **GDPR-compliant**: Zero pain to be GDPR-compliant. +- **SQL**: most SQL-92 support. +- **Decentralize**: decentralize with our consensus algorithm DH-RPC & Kayak. +- **Privacy**: access with granted permission and Encryption Pass. +- **Immutable**: query history in CQL is immutable and trackable. +- **Permission**: grant permission with column level ACL and SQL pattern whitelist. -CovenantSQL 具备以下特点: +We believe [On the next Internet, everyone should have a complete **Data Rights**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) -* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 -* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 -* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 -* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 +**One Line Makes Data on Blockchain** -我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) +```go +sql.Open("cql", dbURI) +``` -## CovenantSQL 原理 +## What is CQL? -CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: - -* 主链节点: - * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 -* 侧链矿工: - * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 - * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 -* 数据库用户: - * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 - * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 - * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 - -![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) - -* 第一层:**全局共识层**(主链,架构图中的中间环): - * 整个网络中只有一个主链。 - * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 -* 第二层:**SQL 共识层**(子链,架构图中的两边环): - * 每个数据库都有自己独立的子链。 - * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 -* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): - * 每个数据库都有自己独立的分布式引擎。 - * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file +- Open source alternative of [Amazon QLDB](https://aws.amazon.com/qldb/) +- Just like [filecoin](https://filecoin.io/) + [IPFS](https://ipfs.io/) is the decentralized file system, CQL is the decentralized database \ No newline at end of file From ff77caac52365482e04f1464ec39aa2baa873c73 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:59:35 +0800 Subject: [PATCH 225/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/intro.md | 47 ++++++------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/intro.md b/website/translated_docs/zh-CN/version-0.5.0/intro.md index 0fa6d06..e92de5e 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/intro.md @@ -33,41 +33,24 @@ original_id: intro alt="Join the chat at https://gitter.im/CovenantSQL/CovenantSQL">

-CovenantSQL 是应用区块链技术构建的去中心化 SQL 云数据库, +CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: -结合了区块链、共享经济、分布式数据库的优势,保障了用户隐私及对数据的所有权。 +- **GDPR-compliant**: Zero pain to be GDPR-compliant. +- **SQL**: most SQL-92 support. +- **Decentralize**: decentralize with our consensus algorithm DH-RPC & Kayak. +- **Privacy**: access with granted permission and Encryption Pass. +- **Immutable**: query history in CQL is immutable and trackable. +- **Permission**: grant permission with column level ACL and SQL pattern whitelist. -CovenantSQL 具备以下特点: +We believe [On the next Internet, everyone should have a complete **Data Rights**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) -* **SQL接口**: 支持 SQL-92 标准,传统 App 几乎0修改即可数据上链 -* **去中心化**: 基于独有的高效拜占庭容错共识算法 Kayak 实现的去中心化结构 -* **不可篡改**: CovenantSQL 中的 Query 历史记录是可追溯的 -* **隐私**: 如果 Bitcoin 是人们的私人钱包,那么 CovenantSQL 就是是人们的去中心化的私密数据库 +**One Line Makes Data on Blockchain** -我们相信 [在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) +```go +sql.Open("cql", dbURI) +``` -## CovenantSQL 原理 +## What is CQL? -CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三种角色组成: - -* 主链节点: - * 通过去中心化的架构,DPoS 模式的共识机制对矿工和用户进行撮合、协调、仲裁 -* 侧链矿工: - * 所有人都可以通过运行 Covenant Miner 来提供数据库服务来赚取奖励 - * 通过 ETLS 传输层加密、应用层签名、落盘加密、端到端加密来保证用户数据隐私 -* 数据库用户: - * 用户通过一个私钥就可以创建指定数量节点的分布式数据库,存储自己的结构化数据 - * 数据矿工的分布和地址仅对数据库用户可见,防止用户数据被嗅探 - * 通过 **去中心化的高可用的架构** 和 **Miner 押金机制**,用户的数据可以在成本和可靠性、可用性上达到平衡可控 - -![CovenantSQL 3 Layer design](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/logo/arch.png) - -* 第一层:**全局共识层**(主链,架构图中的中间环): - * 整个网络中只有一个主链。 - * 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。 -* 第二层:**SQL 共识层**(子链,架构图中的两边环): - * 每个数据库都有自己独立的子链。 - * 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。 -* 第三层:**数据储存层**(支持 SQL-92 的数据库引擎): - * 每个数据库都有自己独立的分布式引擎。 - * 主要负责:数据库存储和加密;查询处理和签名;高效索引。 \ No newline at end of file +- Open source alternative of [Amazon QLDB](https://aws.amazon.com/qldb/) +- Just like [filecoin](https://filecoin.io/) + [IPFS](https://ipfs.io/) is the decentralized file system, CQL is the decentralized database \ No newline at end of file From cc269113268ccd0a057bc089e319ed5841e85d0c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 15:59:41 +0800 Subject: [PATCH 226/421] New translations arch.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/arch.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/arch.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch.md b/website/translated_docs/zh-CN/version-0.5.0/arch.md new file mode 100644 index 0000000..f752e12 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/arch.md @@ -0,0 +1,59 @@ +--- +id: version-0.5.0-arch +title: Architecture +original_id: arch +--- +## 3 Layers Arch + +![CovenantSQL 3 Layer design](https://github.com/CovenantSQL/CovenantSQL/raw/ed2878359345cd86e4221f14cd59e4654361b64e/logo/arch.png) + +- Layer 1: **Global Consensus Layer** (the main chain, the middle ring in the architecture diagram): + - There will only be one main chain throughout the network. + - Mainly responsible for database Miner and the user’s contract matching, transaction settlement, anti-cheating, shard chain lock hash and other global consensus matters. +- Layer 2: **SQL Consensus Layer** (shard chain, rings on both sides): + - Each database will have its own separate shard chain. + - Mainly responsible for: the signature, delivery and consistency of the various Transactions of the database. The data history of the permanent traceability is mainly implemented here, and the hash lock is performed in the main chain. +- Layer 3: **Datastore Layer** (database engine with SQL-92 support): + - Each Database has its own independent distributed engine. + - Mainly responsible for: database storage & encryption, query processing & signature, efficient indexing. + +## Consensus Algorithm + +CQL supports 2 kinds of consensus algorithm: + +1. DPoS (Delegated Proof-of-Stake) is applied in `Eventually consistency mode` database and also `Layer 1 (Global Consensus Layer)` in BlockProducer. CQL miners pack all SQL queries and its signatures by the client into blocks thus form a blockchain. We named the algorithm [`Xenomint`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/xenomint). +2. BFT-Raft (Byzantine Fault-Toleranted Raft)bft-raft is applied in `Strong consistency mode` database. We named our implementation [`Kayak`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/kayak). The CQL miner leader does a `Two-Phase Commit` with `Kayak` to support `Transaction`.transaction + +CQL database consistency mode and node count can be selected in database creation with command `cql create '{"UseEventualConsistency": true, "Node": 3}'` + +## Comparison + +| | Ethereum | Hyperledger Fabric | Amazon QLDB | CovenantSQL | +| ---------------------------- | ----------------- | ---------------------- | ----------- | -------------------------------------------------------------------- | +| **Dev language** | Solidity, ewasm | Chaincode (Go, NodeJS) | ? | Python, Golang, Java, PHP, NodeJS, MatLab | +| **Dev Pattern** | Smart Contract | Chaincode | SQL | SQL | +| **Open Source** | Y | Y | N | Y | +| **Nodes for HA** | 3 | 15 | ? | 3 | +| **Column Level ACL** | N | Y | ? | Y | +| **Data Format** | File | Key-value | Document | Filefuse, Key-value, Structured | +| **Storage Encryption** | N | API | Y | Y | +| **Data Desensitization** | N | N | N | Y | +| **Multi-tenant** | DIY | DIY | N | Y | +| **Throughput (1s delay)** | 15~10 tx/s | 3500 tx/s | ? | 11065 tx/s (Eventually Consistency) +1866 tx/s (Strong Consistency) | +| **Consistency Delay** | 2~6 min | < 1 s | ? | < 10 ms | +| **Secure for Open Internet** | Y | N | Only in AWS | Y | +| **Consensus** | PoW + PoS(Casper) | CFT | ? | DPoS (Eventually Consistency) +BFT-Raft (Strong Consistency) | + +### FootNotes + +- BFT-Raft: A CQL leader offline needs CQL Block Producer to decide whether to wait for leader online for data integrity or promote a follower node for availability. This part is still under construction and any advice is welcome. + +- Transaction: Talking about `ACID`, CQL has full "Consistency, Isolation, Durability" and a limited `Atomicity` support. That is even under strong consistency mode, CQL transaction is only supported on the leader node. If you want to do "read `v`, `v++`, write `v` back" parallelly and atomically, then the only way is "read `v` from the leader, `v++`, write `v` back to leader" + +- FUSE: CQL has a [simple FUSE](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql-fuse) support adopted from CockroachDB. The performance is not very ideal and still has some issues. But it can pass fio test like: + + ```bash + fio --debug=io --loops=1 --size=8m --filename=../mnt/fiotest.tmp --stonewall --direct=1 --name=Seqread --bs=128k --rw=read --name=Seqwrite --bs=128k --rw=write --name=4krandread --bs=4k --rw=randread --name=4krandwrite --bs=4k --rw=randwrite + ``` \ No newline at end of file From 4eef8e5a0d4eb7f99ae6d3bc6a7c9082b89609a1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:10 +0800 Subject: [PATCH 227/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/deployment.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/translated_docs/zh-CN/deployment.md b/website/translated_docs/zh-CN/deployment.md index 451e55a..09a2b00 100644 --- a/website/translated_docs/zh-CN/deployment.md +++ b/website/translated_docs/zh-CN/deployment.md @@ -61,7 +61,7 @@ docker-compose ps Confirm that all components are in the `Up` state -```shell +```bash Name Command State Ports ------------------------------------------------------------------------------------------------------ covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp @@ -84,20 +84,20 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` The command will return the connection string of the created database instance -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` @@ -105,13 +105,13 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: -```shell +```bash docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode -```shell +```bash Connected with driver covenantsql (develop) Type "help" for help. @@ -129,7 +129,7 @@ SELECT * FROM test; After that, it will get the following output: -```shell +```bash co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; From 7c2be0b34407a8713f169d06c0e12fca7d704a60 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:11 +0800 Subject: [PATCH 228/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_golang.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md index f3bd07a..482d5d3 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md @@ -17,7 +17,7 @@ original_id: driver_golang Install it with: -```shell +```bash go get github.com/CovenantSQL/CovenantSQL/client ``` From 002c760cfd4e21b44b8c756ad3a4f1ea63efbb12 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:15 +0800 Subject: [PATCH 229/421] New translations getting-started-zh.md (Chinese Simplified) --- .../version-0.5.0/bck/getting-started-zh.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md index ad9178a..855ce18 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md @@ -86,7 +86,7 @@ CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三 ### 使用 cql 命令行工具创建数据库 -```shell +```bash ./cql -config config.yaml -create 1 ``` @@ -99,7 +99,7 @@ CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三 ### 使用 cql 命令行工具访问数据库 -```shell +```bash ./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` @@ -120,7 +120,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): -```shell +```bash ./cql-utils -tool confgen ``` @@ -151,7 +151,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): -```shell +```bash ./cql-utils -tool addrgen -private ~/.cql/private.key ``` @@ -164,7 +164,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): -```shell +```bash ./cql -config ~/.cql/config.yaml -get-balance ``` @@ -200,7 +200,7 @@ Docker-Compose:https://docs.docker.com/compose/install/ 执行以下的命令在本地运行 CovenantSQL -```shell +```bash git clone https://github.com/CovenantSQL/CovenantSQL cd CovenantSQL make docker @@ -211,13 +211,13 @@ make start ### 检查运行状态 -```shell +```bash docker-compose ps ``` 确认所有组件都处于 `Up` 的状态 -```shell +```bash Name Command State Ports ------------------------------------------------------------------------------------------------------ covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp @@ -242,19 +242,19 @@ covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tc 使用 `cql` 命令并使用 `create` 参数提供所需的数据库节点数量创建数据库实例,例如:创建一个单节点的数据库实例 -```shell +```bash cql -config config/config.yaml -create 1 ``` > 修改 `create` 参数的值,可以创建运行在多节点上的实例,例如:创建两个节点的实例 -```shell +```bash cql -config config/config.yaml -create 2 ``` 命令会返回创建的数据库实例的连接串 -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` @@ -262,13 +262,13 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 使用 `cql` 命令并使用 `dsn` 参数提供数据库实例的连接串进行数据库访问 -```shell +```bash cql -config config/config.yaml -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` 会得到如下输出,并进入 `cql` 交互命令行模式 -```shell +```bash Connected with driver covenantsql (develop) Type "help" for help. @@ -286,7 +286,7 @@ SELECT * FROM test; 会得到如下输出 -```shell +```bash co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; @@ -328,7 +328,7 @@ co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> 可以执行 `go get` 命令进行安装 -```shell +```bash go get github.com/CovenantSQL/CovenantSQL/client ``` From 72f46be7d9caa051657b2cc6491674099c09348d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:17 +0800 Subject: [PATCH 230/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/adpater.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md index fb28e3c..bbf194f 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/adpater.md +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -34,7 +34,7 @@ Create new database using `cql create` command and provide database instance req For example, create a single node database instance: -```shell +```bash docker run -it --rm \ -v ~/.cql/config.yaml:/app/config.yaml \ -v ~/.cql/private.key:/app/private.key \ @@ -44,7 +44,7 @@ docker run -it --rm \ This command would produce a database connection string (DSN) similar to following example. -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` From f4437b72404cc1bb26cb53d4b331bec4e7b6ce75 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:18 +0800 Subject: [PATCH 231/421] New translations deployment-en.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment-en.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md index b97f767..9e1ca7a 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md @@ -62,7 +62,7 @@ docker-compose ps Confirm that all components are in the `Up` state -```shell +```bash Name Command State Ports ------------------------------------------------------------------------------------------------------ covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp @@ -85,20 +85,20 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` The command will return the connection string of the created database instance -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` @@ -106,13 +106,13 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: -```shell +```bash docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode -```shell +```bash Connected with driver covenantsql (develop) Type "help" for help. @@ -130,7 +130,7 @@ SELECT * FROM test; After that, it will get the following output: -```shell +```bash co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; From b4a4ec2fceceb3db8406cd2e80707e0525171625 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:19 +0800 Subject: [PATCH 232/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md index db5defa..7b947e5 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -17,7 +17,7 @@ Before using `Python SDK`, an adapter deployment is required, please see [Deploy Install `PyCovenantSQL` using pip: -```shell +```bash $ python3 -m pip install PyCovenantSQL ``` From b9946b87a6e1481876605c38a0cc2e9f1fff4d93 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:21 +0800 Subject: [PATCH 233/421] New translations guide-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/guide-zh.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md index 444aba4..005ca3d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md @@ -15,7 +15,7 @@ original_id: guide-zh ### 使用 cql 命令行工具创建数据库 -```shell +```bash ./cql -config config.yaml -create 1 ``` @@ -28,7 +28,7 @@ original_id: guide-zh ### 使用 cql 命令行工具访问数据库 -```shell +```bash ./cql -config config.yaml -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` @@ -49,7 +49,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 我们的测试网支持您创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(需要输入主密码): -```shell +```bash ./cql-utils -tool confgen ``` @@ -80,7 +80,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): -```shell +```bash ./cql-utils -tool addrgen -private ~/.cql/private.key ``` @@ -93,7 +93,7 @@ CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**, 使用 cql 命令行工具查询余额(未加 -config 参数时,命令会自动找 ~/.cql 目录的 config.yaml 文件): -```shell +```bash ./cql -config ~/.cql/config.yaml -get-balance ``` From 6b6494185357f051ed9ade61c7f359bd4cd1b96c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:32 +0800 Subject: [PATCH 234/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_golang.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/driver_golang.md b/website/translated_docs/zh-CN/driver_golang.md index c3d2d84..e1fec93 100644 --- a/website/translated_docs/zh-CN/driver_golang.md +++ b/website/translated_docs/zh-CN/driver_golang.md @@ -16,7 +16,7 @@ title: Golang Install it with: -```shell +```bash go get github.com/CovenantSQL/CovenantSQL/client ``` From ab14787c34b72d91dad43d3e70b857fa2f8274b0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:34 +0800 Subject: [PATCH 235/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 115 ++++++++++---------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 179e060..450b190 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -2,67 +2,67 @@ id: quickstart title: Quick Start --- -## CovenantSQL 工具包 +## CovenantSQL Client -### 工具包安装 +### Install -请根据您使用的操作系统平台选择安装方式: +Please choose the installation method according to the operating system platform you use: -#### MacOS 平台 +#### MacOS -- 🍺 Homebrew 用户可以直接在命令行: +- 🍺 Homebrew users can just run: ```bash brew install cql ``` -- 非 Homebrew,可以执行: +- non-Homebrew users can run: ```bash sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` -#### Linux 平台 +#### Linux -在命令行中执行: +Just run: ```bash sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` -安装完成后可以执行下面的命令,查看是否安装成功 +After the installation is complete, you can execute the following command to check whether the installation is successful. ```bash cql version ``` -如果对于 MacOS 或者 Linux 平台有任何错误,可以执行如下命令进行修复: +If you have any errors on the MacOS or Linux, you can try the following to fix it: ```bash sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -如果问题依旧存在请在我们的 GitHub 页面 [提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +If the problem persists please check out our GitHub page [Submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 -### 工具包介绍 +### Utils -| 工具名 | 介绍 | -| ---------- | ---------------------------------------------------------------- | -| cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | -| cql-fuse | CovenantSQL 的 FUSE 客户端,可以把 CovenantSQL 数据库 mount 成文件系统 | -| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | -| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | +| Tool | Introduction | +| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` The command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | -> Windows 平台我们稍后发布,有需求请在 GitHub [提 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 +> Windows platform we will release later, if there is a need please [Submit Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 -### 测试网快速接入 +### TestNet -目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 +At present, we have released the test network v0.5.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". -测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: +The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: ```bash mkdir -p ~/.cql/testnet-conf @@ -71,65 +71,65 @@ curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key chmod 600 ~/.cql/testnet-conf/private.key ``` -**测试网注**: +**TestNet Notes**: -> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> The "public account" is public and only for testing. Please do not store your application information in the database created by the "public account". We will clean the database data from time to time. > -> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持 `create 3` 创建 3 个节点组成的数据库。 +> The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. -## 创建数据库 +## Create a database ```bash cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ -wait-tx-confirm '{"node":1}' ``` -命令执行耗时较长,大约 30s 之后控制台会输出: +The command execution takes a little long time, and the console outputs after about 30 seconds: > covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ​ -这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 +This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. -> 命令执行耗时较长,大致过程为: +> Command execution takes some time, and the general process is: > -> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 -> 2. 数据库创建请求在 其它出块节点 进行验证和确认 -> 3. SQLChain 的符合条件的 Miner 收到数据库任务 -> 4. SQLChian 组建 Kayak 数据库集群 -> 5. 所有 Miner 准备就绪等待请求 +> 1. The "Block Producer" that received the request performs a match of Miner and database creation requests. +> 2. Database creation request is verified and confirmed at other "Block Producer" nodes +> 3. Eligible Miner on SQLChain receives database task +> 4. SQLChain Miners builds a database cluster with Kayak +> 5. All Miners are ready to wait for a database request -## 访问数据库 +## Access the database -```shell +```bash cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` -连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 +After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. -## SQLChain 区块浏览器 +## SQLChain Explorer -CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 +One feature of CovenantSQL is that its query records are **immutable and traceable**, you can query the operation of a database through \[Test Web Block Browser\] (https://explorer.dbhub.org/) recording. -> 测试网的`区块浏览器`目前是开放权限的,使用 TestNet 的公共 Key 创建并且知道数据库 ID 的人都能看到您的数据 +> The TestNet's SQLChain Explorer is currently open-access, and anyone who knows the database ID can manipulate your data using TestNet's public key. -查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 。你可以看到使用 TestNet 的 Key 创建的所有数据的信息: +Please fill in your database ID in the upper right corner of the page. For example: `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872`. You can see information about all the data created using TestNet's Key: ![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) -> **如果想要创建自己的私有数据库,需要从头开始创建一个新的公私钥对,请参考下面的章节。** +> **If you want to create your own private database, you need to create a new public-private key pair from scratch, please refer to the following section.** -## 创建新账号 +## Create your own account -我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,可以加上 `-no-password` 留空): +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): ```bash cql generate -no-password config ``` -输出: +Output: INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 "/home/work/.cql" already exists. @@ -150,35 +150,34 @@ cql generate -no-password config Generated config. -该命令会为你在~目录下创建一个 `.cql` 目录: +This command will create a `.cql` directory for you in your `$HOME` directory: -- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; -- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 +- `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; +- `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. -再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): +Let's continue to generate the account address (also called the wallet address, CovenantSQL address): ```bash cql wallet -no-password ``` -输出: +Output: -```toml -wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c -``` + wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c + -你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 +You can get the test PTC here with the wallet address obtained above: \[Request PTC\] (https://testnet.covenantsql.io/). -使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): +After up to 2 minutes, you can use the cql command line tool to check the balance: ```bash cql wallet -no-password -balance all ``` -输出: +output: - Particle balance is: 100 + Particle balance is: 10000000 Wave balance is: 0 -恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file +Congratulations, you have received our PTC stable currency, and you can start using CovenantSQL now. You can refer to [Golang uses CovenantSQL documentation](./driver_golang) for development. \ No newline at end of file From 6d7ecb4bae71601968853ca3f851705c673addc4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:36 +0800 Subject: [PATCH 236/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index bf93a78..d7c12c9 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -33,7 +33,7 @@ Create new database using `cql create` command and provide database instance req For example, create a single node database instance: -```shell +```bash docker run -it --rm \ -v ~/.cql/config.yaml:/app/config.yaml \ -v ~/.cql/private.key:/app/private.key \ @@ -43,7 +43,7 @@ docker run -it --rm \ This command would produce a database connection string (DSN) similar to following example. -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` From 6b9f7de8928be3d5921fadcf57f9afa7ed68927b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:37 +0800 Subject: [PATCH 237/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md index c273518..62f739b 100644 --- a/website/translated_docs/zh-CN/driver_python.md +++ b/website/translated_docs/zh-CN/driver_python.md @@ -16,7 +16,7 @@ Before using `Python SDK`, an adapter deployment is required, please see [Deploy Install `PyCovenantSQL` using pip: -```shell +```bash $ python3 -m pip install PyCovenantSQL ``` From b85ae1e1de16297cc02fbd9fb8013e316c605dc7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:47 +0800 Subject: [PATCH 238/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quickstart.md | 115 +++++++++--------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 9a58bf1..35ab67d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -3,67 +3,67 @@ id: version-0.5.0-quickstart title: Quick Start original_id: quickstart --- -## CovenantSQL 工具包 +## CovenantSQL Client -### 工具包安装 +### Install -请根据您使用的操作系统平台选择安装方式: +Please choose the installation method according to the operating system platform you use: -#### MacOS 平台 +#### MacOS -- 🍺 Homebrew 用户可以直接在命令行: +- 🍺 Homebrew users can just run: ```bash brew install cql ``` -- 非 Homebrew,可以执行: +- non-Homebrew users can run: ```bash sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` -#### Linux 平台 +#### Linux -在命令行中执行: +Just run: ```bash sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` -安装完成后可以执行下面的命令,查看是否安装成功 +After the installation is complete, you can execute the following command to check whether the installation is successful. ```bash cql version ``` -如果对于 MacOS 或者 Linux 平台有任何错误,可以执行如下命令进行修复: +If you have any errors on the MacOS or Linux, you can try the following to fix it: ```bash sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -如果问题依旧存在请在我们的 GitHub 页面 [提交 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +If the problem persists please check out our GitHub page [Submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 -### 工具包介绍 +### Utils -| 工具名 | 介绍 | -| ---------- | ---------------------------------------------------------------- | -| cql | CovenantSQL 的客户端,`cql console` 命令类似 mysql 命令,用于执行 SQL。还有其他丰富的工具链 | -| cql-fuse | CovenantSQL 的 FUSE 客户端,可以把 CovenantSQL 数据库 mount 成文件系统 | -| cql-minerd | CovenantSQL 矿工客户端,用于运行数据库赚取奖励,以后会开放加入 | -| cqld | CovenantSQL 主链节点,主要由 CovenantLabs 以及合作伙伴以 DPoS 模式运行 | +| Tool | Introduction | +| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` The command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | -> Windows 平台我们稍后发布,有需求请在 GitHub [提 Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 +> Windows platform we will release later, if there is a need please [Submit Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 -### 测试网快速接入 +### TestNet -目前,我们已经发布了测试网 v0.5.0,供大家进行原理性验证和体验。你可以选在使用公共的测试账号快速进行接入测试。 +At present, we have released the test network v0.5.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". -测试账号的配置文件和私钥:[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (密码为空),或者使用以下命令: +The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: ```bash mkdir -p ~/.cql/testnet-conf @@ -72,65 +72,65 @@ curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key chmod 600 ~/.cql/testnet-conf/private.key ``` -**测试网注**: +**TestNet Notes**: -> 该账号是公共的且只供测试使用,请不要在该账号创建的数据库中存放你的应用信息,我们会不定期清理数据库数据。 +> The "public account" is public and only for testing. Please do not store your application information in the database created by the "public account". We will clean the database data from time to time. > -> 测试网暂时由 3 个 Miner 组成,所以暂时最大只支持 `create 3` 创建 3 个节点组成的数据库。 +> The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. -## 创建数据库 +## Create a database ```bash cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ -wait-tx-confirm '{"node":1}' ``` -命令执行耗时较长,大约 30s 之后控制台会输出: +The command execution takes a little long time, and the console outputs after about 30 seconds: > covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ​ -这里表示你提交了 `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 这个数据库的创建请求到主链,并创建数据库完成。 +This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. -> 命令执行耗时较长,大致过程为: +> Command execution takes some time, and the general process is: > -> 1. 收到请求的 出块节点(Block Producer)进行 Miner 和数据库创建请求的撮合 -> 2. 数据库创建请求在 其它出块节点 进行验证和确认 -> 3. SQLChain 的符合条件的 Miner 收到数据库任务 -> 4. SQLChian 组建 Kayak 数据库集群 -> 5. 所有 Miner 准备就绪等待请求 +> 1. The "Block Producer" that received the request performs a match of Miner and database creation requests. +> 2. Database creation request is verified and confirmed at other "Block Producer" nodes +> 3. Eligible Miner on SQLChain receives database task +> 4. SQLChain Miners builds a database cluster with Kayak +> 5. All Miners are ready to wait for a database request -## 访问数据库 +## Access the database -```shell +```bash cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` -连接上数据库后,你可以按你操作数据库的习惯来操作 CovenantSQL 上的数据库。比如执行 `CREATE TABLE` 创建表、`SELECT` 查询数据等操作。 +After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. -## SQLChain 区块浏览器 +## SQLChain Explorer -CovenantSQL 有一个特性是**其操作记录是不可变且可跟踪的**,你可以通过 [测试网区块浏览器](https://explorer.dbhub.org/) 来查询某个数据库的操作记录。 +One feature of CovenantSQL is that its query records are **immutable and traceable**, you can query the operation of a database through \[Test Web Block Browser\] (https://explorer.dbhub.org/) recording. -> 测试网的`区块浏览器`目前是开放权限的,使用 TestNet 的公共 Key 创建并且知道数据库 ID 的人都能看到您的数据 +> The TestNet's SQLChain Explorer is currently open-access, and anyone who knows the database ID can manipulate your data using TestNet's public key. -查询时,请在其页面右上角填入你的数据库 ID。例如:`0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` 。你可以看到使用 TestNet 的 Key 创建的所有数据的信息: +Please fill in your database ID in the upper right corner of the page. For example: `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872`. You can see information about all the data created using TestNet's Key: ![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) -> **如果想要创建自己的私有数据库,需要从头开始创建一个新的公私钥对,请参考下面的章节。** +> **If you want to create your own private database, you need to create a new public-private key pair from scratch, please refer to the following section.** -## 创建新账号 +## Create your own account -我们的测试网支持你创建自己的的账号,并在自己的账号下创建数据库。通过以下的命令创建账号(会询问设置主密码,可以加上 `-no-password` 留空): +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): ```bash cql generate -no-password config ``` -输出: +Output: INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 "/home/work/.cql" already exists. @@ -151,35 +151,34 @@ cql generate -no-password config Generated config. -该命令会为你在~目录下创建一个 `.cql` 目录: +This command will create a `.cql` directory for you in your `$HOME` directory: -- `~/.cql/private.key`: 为你生成的私钥通过主密码加密保存在该文件中,你的账号地址需要使用该文件创建; -- `~/.cql/config.yaml`: 为你生成的配置,cql 可以通过读取该配置来访问 CovenantSQL 测试网。 +- `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; +- `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. -再运行命令用来生成账号地址(也叫钱包地址、CovenantSQL 地址): +Let's continue to generate the account address (also called the wallet address, CovenantSQL address): ```bash cql wallet -no-password ``` -输出: +Output: -```toml -wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c -``` + wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c + -你可以在这里回复上面得到的钱包地址 [GitHub Issue](https://github.com/CovenantSQL/CovenantSQL/issues/283),我们会为你的钱包充值。 +You can get the test PTC here with the wallet address obtained above: \[Request PTC\] (https://testnet.covenantsql.io/). -使用 cql 命令行工具查询余额(可以添加 -config 参数,指定其他的 config.yaml 所在目录): +After up to 2 minutes, you can use the cql command line tool to check the balance: ```bash cql wallet -no-password -balance all ``` -输出: +output: - Particle balance is: 100 + Particle balance is: 10000000 Wave balance is: 0 -恭喜,你已收到我们发出的 PTC 稳定币,现在即可开始使用 CovenantSQL, 你可以参考 [Golang 使用 CovenantSQL 文档](./development) 进行开发。 \ No newline at end of file +Congratulations, you have received our PTC stable currency, and you can start using CovenantSQL now. You can refer to [Golang uses CovenantSQL documentation](./driver_golang) for development. \ No newline at end of file From c8f755bba683251c10ec67b697583480fd08c12b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 16:46:51 +0800 Subject: [PATCH 239/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md index 5366a86..a5860d8 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -62,7 +62,7 @@ docker-compose ps Confirm that all components are in the `Up` state -```shell +```bash Name Command State Ports ------------------------------------------------------------------------------------------------------ covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp @@ -85,20 +85,20 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes -```shell +```bash docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' ``` The command will return the connection string of the created database instance -```shell +```bash covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` @@ -106,13 +106,13 @@ covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: -```shell +```bash docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode -```shell +```bash Connected with driver covenantsql (develop) Type "help" for help. @@ -130,7 +130,7 @@ SELECT * FROM test; After that, it will get the following output: -```shell +```bash co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); CREATE TABLE co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; From abe37059352204d1e7bb1834b79c1c8468e26286 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:18:38 +0800 Subject: [PATCH 240/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/deployment.md | 92 ++++++++++----------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/website/translated_docs/zh-CN/deployment.md b/website/translated_docs/zh-CN/deployment.md index 09a2b00..51ac83a 100644 --- a/website/translated_docs/zh-CN/deployment.md +++ b/website/translated_docs/zh-CN/deployment.md @@ -61,20 +61,19 @@ docker-compose ps Confirm that all components are in the `Up` state -```bash - Name Command State Ports ------------------------------------------------------------------------------------------------------- -covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp -covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp -covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp -covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp -covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp -covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp -covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp -covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp -covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp -``` + Name Command State Ports + ------------------------------------------------------------------------------------------------------ + covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp + covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp + covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp + covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp + covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp + covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp + covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp + covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp + covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp + covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + ## Operate CovenantSQL @@ -97,9 +96,8 @@ docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no The command will return the connection string of the created database instance -```bash -covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 -``` + covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ### Accessing the database @@ -111,43 +109,41 @@ docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -n After that, it will get the following output, and enter the `cql` interactive command line mode -```bash -Connected with driver covenantsql (develop) -Type "help" for help. - -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. +Connected with driver covenantsql (develop) Type "help" for help. -```sql -CREATE TABLE test (test TEXT); -SHOW TABLES; -INSERT INTO test VALUES("happy"); -SELECT * FROM test; -``` +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> -After that, it will get the following output: +
The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + + ```sql + CREATE TABLE test (test TEXT); + SHOW TABLES; + INSERT INTO test VALUES("happy"); + SELECT * FROM test; + -```bash -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); -CREATE TABLE -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; - name ------- - test -(1 row) - -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); -INSERT -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; - test -------- - happy -(1 row) +After that, it will get the following output: -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> -``` + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); + CREATE TABLE + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name + ------ + test + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); + INSERT + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test + ------- + happy + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line From fbba18e2b350e2518a2b54c0480e55701084dcd6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:25:38 +0800 Subject: [PATCH 241/421] New translations deployment.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/deployment.md | 92 +++++++++---------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md index a5860d8..dc52541 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -62,20 +62,19 @@ docker-compose ps Confirm that all components are in the `Up` state -```bash - Name Command State Ports ------------------------------------------------------------------------------------------------------- -covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp -covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp -covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp -covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp -covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp -covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp -covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp -covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp -covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp -covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp -``` + Name Command State Ports + ------------------------------------------------------------------------------------------------------ + covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp + covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp + covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp + covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp + covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp + covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp + covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp + covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp + covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp + covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + ## Operate CovenantSQL @@ -98,9 +97,8 @@ docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no The command will return the connection string of the created database instance -```bash -covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 -``` + covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ### Accessing the database @@ -112,43 +110,41 @@ docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -n After that, it will get the following output, and enter the `cql` interactive command line mode -```bash -Connected with driver covenantsql (develop) -Type "help" for help. - -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> ``` -The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. +Connected with driver covenantsql (develop) Type "help" for help. -```sql -CREATE TABLE test (test TEXT); -SHOW TABLES; -INSERT INTO test VALUES("happy"); -SELECT * FROM test; -``` +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> -After that, it will get the following output: +
The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + + ```sql + CREATE TABLE test (test TEXT); + SHOW TABLES; + INSERT INTO test VALUES("happy"); + SELECT * FROM test; + -```bash -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); -CREATE TABLE -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; - name ------- - test -(1 row) - -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); -INSERT -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; - test -------- - happy -(1 row) +After that, it will get the following output: -co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> -``` + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); + CREATE TABLE + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name + ------ + test + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); + INSERT + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test + ------- + happy + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line From 970d28e80d351afbfc7981254e02ddd9dac176fd Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:25 +0800 Subject: [PATCH 242/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md index d3e3353..d5a2fef 100644 --- a/website/translated_docs/zh-CN/cql_intro.md +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -1,6 +1,6 @@ --- id: cql_intro -title: Intro +title: Overview --- CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). From 95f5f4e1e6692d0b6f883bb8a40fa5e7c2d0adfc Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:28 +0800 Subject: [PATCH 243/421] New translations usecase_traditional_app.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase_traditional_app.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/usecase_traditional_app.md b/website/translated_docs/zh-CN/usecase_traditional_app.md index 6a746a0..a637d52 100644 --- a/website/translated_docs/zh-CN/usecase_traditional_app.md +++ b/website/translated_docs/zh-CN/usecase_traditional_app.md @@ -2,7 +2,7 @@ id: usecase_traditional_app title: Traditional App --- -### Privacy data +## Privacy data If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: @@ -10,14 +10,14 @@ If you are a developper of password management tools just like [1Password](https 2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users. 3. Regulation: CQL naturally comply with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation). -### IoT storage +## IoT storage CQL miners are deployed globally, IoT node can write to nearest CQL miner directly. 1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper. 2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable. -### Open data service +## Open data service For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs. @@ -25,6 +25,6 @@ For example, you are the most detailed Bitcoin OHLC data maintainer. You can dir 2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing, like [this](https://explorer.dbhub.org/dbs/7a51191ae06afa22595b3904dc558d41057a279393b22650a95a3fc610e1e2df/requests/f466f7bf89d4dd1ece7849ef3cbe5c619c2e6e793c65b31966dbe4c7db0bb072) 3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates. -### Secure storage +## Secure storage Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs. \ No newline at end of file From e03f9f5c1c7f0bef6c1780ead5de31dd3cf68641 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:31 +0800 Subject: [PATCH 244/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 450b190..24041e1 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -13,24 +13,24 @@ Please choose the installation method according to the operating system platform - 🍺 Homebrew users can just run: ```bash -brew install cql -``` + brew install cql + ``` - non-Homebrew users can run: -```bash -sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ - tar xzv -C /usr/local/bin/ --strip-components=1' -``` + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` #### Linux -Just run: +- Just run: -```bash -sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ -tar xzv -C /usr/local/bin/ --strip-components=1' -``` + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` After the installation is complete, you can execute the following command to check whether the installation is successful. From 8713b90909475f051b3d93b4a8f788af4152b8c5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:38 +0800 Subject: [PATCH 245/421] New translations usecase_traditional_app.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/usecase_traditional_app.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md index d42cd24..f6fff06 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md @@ -3,7 +3,7 @@ id: version-0.5.0-usecase_traditional_app title: Traditional App original_id: usecase_traditional_app --- -### Privacy data +## Privacy data If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: @@ -11,14 +11,14 @@ If you are a developper of password management tools just like [1Password](https 2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users. 3. Regulation: CQL naturally comply with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation). -### IoT storage +## IoT storage CQL miners are deployed globally, IoT node can write to nearest CQL miner directly. 1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper. 2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable. -### Open data service +## Open data service For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs. @@ -26,6 +26,6 @@ For example, you are the most detailed Bitcoin OHLC data maintainer. You can dir 2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing, like [this](https://explorer.dbhub.org/dbs/7a51191ae06afa22595b3904dc558d41057a279393b22650a95a3fc610e1e2df/requests/f466f7bf89d4dd1ece7849ef3cbe5c619c2e6e793c65b31966dbe4c7db0bb072) 3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates. -### Secure storage +## Secure storage Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs. \ No newline at end of file From 5a1490d5dc68c5cbc562960730f3f831e55f5098 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:39 +0800 Subject: [PATCH 246/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql_intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md index 93311be..e760433 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-cql_intro -title: Intro +title: Overview original_id: cql_intro --- CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). From b242a676f8bd4ee1f632c5dfe4e7ec7cac58251a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 19 Apr 2019 17:43:47 +0800 Subject: [PATCH 247/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/quickstart.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 35ab67d..a4d1183 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -14,24 +14,24 @@ Please choose the installation method according to the operating system platform - 🍺 Homebrew users can just run: ```bash -brew install cql -``` + brew install cql + ``` - non-Homebrew users can run: -```bash -sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ - tar xzv -C /usr/local/bin/ --strip-components=1' -``` + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` #### Linux -Just run: +- Just run: -```bash -sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ -tar xzv -C /usr/local/bin/ --strip-components=1' -``` + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` After the installation is complete, you can execute the following command to check whether the installation is successful. From fc82832ecd255ba968a3653102520b98e3434fb6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 14:54:28 +0800 Subject: [PATCH 248/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/intro.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/website/translated_docs/zh-CN/intro.md b/website/translated_docs/zh-CN/intro.md index 4164d24..5a76c76 100644 --- a/website/translated_docs/zh-CN/intro.md +++ b/website/translated_docs/zh-CN/intro.md @@ -24,22 +24,20 @@ title: CovenantSQL Intro GoDoc - - follow on Twitter - - Join the chat at https://gitter.im/CovenantSQL/CovenantSQL + + homebrew

CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: +- **ServerLess**: Free, High Availabile, Auto Sync Database Service for Serverless App - **GDPR-compliant**: Zero pain to be GDPR-compliant. -- **SQL**: most SQL-92 support. -- **Decentralize**: decentralize with our consensus algorithm DH-RPC & Kayak. -- **Privacy**: access with granted permission and Encryption Pass. -- **Immutable**: query history in CQL is immutable and trackable. -- **Permission**: grant permission with column level ACL and SQL pattern whitelist. +- **SQL**: Most SQL-92 support. +- **Decentralize**: Running on Open Internet without Central Coordination. +- **Privacy**: Access with Granted Permission and Encryption Pass. +- **Immutable**: Query History in CQL is Immutable and Trackable. +- **Permission**: Column Level ACL and SQL Pattern Whitelist. We believe [On the next Internet, everyone should have a complete **Data Rights**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) From 5ba247d0c895d9a7470a2be44f208a463c443758 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 14:54:30 +0800 Subject: [PATCH 249/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md index b820313..cc1fb05 100644 --- a/website/translated_docs/zh-CN/qna.md +++ b/website/translated_docs/zh-CN/qna.md @@ -2,4 +2,7 @@ id: qna title: Q&A --- -## TBD \ No newline at end of file +## TBD + +- CQL 的数据库安全是如何做的,怎么防止 51% 攻击? +- CQL 是如何存储数据库的数据的? \ No newline at end of file From d25d3356728857444d08522b3983517ff9d60afe Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 15:04:26 +0800 Subject: [PATCH 250/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/qna.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md index ea2a604..32cbd94 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/qna.md +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -3,4 +3,7 @@ id: version-0.5.0-qna title: Q&A original_id: qna --- -## TBD \ No newline at end of file +## TBD + +- CQL 的数据库安全是如何做的,怎么防止 51% 攻击? +- CQL 是如何存储数据库的数据的? \ No newline at end of file From 5367b6aad1fed9d35272a7eced0b510dba03e5b2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 15:04:38 +0800 Subject: [PATCH 251/421] New translations intro.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/intro.md | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/intro.md b/website/translated_docs/zh-CN/version-0.5.0/intro.md index e92de5e..c340974 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/intro.md @@ -25,22 +25,20 @@ original_id: intro GoDoc - - follow on Twitter - - Join the chat at https://gitter.im/CovenantSQL/CovenantSQL + + homebrew

CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: +- **ServerLess**: Free, High Availabile, Auto Sync Database Service for Serverless App - **GDPR-compliant**: Zero pain to be GDPR-compliant. -- **SQL**: most SQL-92 support. -- **Decentralize**: decentralize with our consensus algorithm DH-RPC & Kayak. -- **Privacy**: access with granted permission and Encryption Pass. -- **Immutable**: query history in CQL is immutable and trackable. -- **Permission**: grant permission with column level ACL and SQL pattern whitelist. +- **SQL**: Most SQL-92 support. +- **Decentralize**: Running on Open Internet without Central Coordination. +- **Privacy**: Access with Granted Permission and Encryption Pass. +- **Immutable**: Query History in CQL is Immutable and Trackable. +- **Permission**: Column Level ACL and SQL Pattern Whitelist. We believe [On the next Internet, everyone should have a complete **Data Rights**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e) From 5d4d826d5150d75e9ea7f14c358409fd369d6cf6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:16 +0800 Subject: [PATCH 252/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql_advance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md index 8bf3cd2..d7b34ca 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md @@ -1,6 +1,6 @@ --- id: version-0.5.0-cql_advance -title: Advance Usage +title: Advanced Usage original_id: cql_advance --- Sub-command `rpc` calls the remote process directly in the CovenantSQL network. From eb2942e59cc1ca3bda7d94f28081d0891f35c4be Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:22 +0800 Subject: [PATCH 253/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_advance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_advance.md b/website/translated_docs/zh-CN/cql_advance.md index 6fdbc28..81b24c2 100644 --- a/website/translated_docs/zh-CN/cql_advance.md +++ b/website/translated_docs/zh-CN/cql_advance.md @@ -1,6 +1,6 @@ --- id: cql_advance -title: Advance Usage +title: Advanced Usage --- Sub-command `rpc` calls the remote process directly in the CovenantSQL network. From bc3764071139005a579223f733e83e398e422053 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:24 +0800 Subject: [PATCH 254/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md index cc1fb05..0d34692 100644 --- a/website/translated_docs/zh-CN/qna.md +++ b/website/translated_docs/zh-CN/qna.md @@ -2,7 +2,28 @@ id: qna title: Q&A --- -## TBD +## Frequently Asked -- CQL 的数据库安全是如何做的,怎么防止 51% 攻击? -- CQL 是如何存储数据库的数据的? \ No newline at end of file +- **Q:** CQL 的数据库安全是如何做的? + + **A:** 不同于传统的数据库,CQL 是运行在开放互联网上的分布式数据库系统。安全方面主要做了如下的工作: + + 1. 密钥体系:CQL 使用 Bitcoin 的 `scep256k1` 曲线的非对称加密算法产生的公私钥对。 + 2. 网络通信:参见 [网络安全](./arch_network)。 + 3. 数据库权限: + +- **Q:** CQL 数据如果是不可篡改的,如何处理数据删除的需求? + + **A:** d + +- **Q:** CQL 是如何存储数据库的数据的? + + **A:** d + +- **Q:** CQL 支持数据量的上限大致是多少? + + **A:** d + +- **Q:** CQL 的数据存储如何计费、收费? + + **A:** d \ No newline at end of file From 807e641377368a4e8a1e572896fcc1cc57c88cbf Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:25 +0800 Subject: [PATCH 255/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 24041e1..69b40e6 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -45,7 +45,7 @@ sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -If the problem persists please check out our GitHub page [Submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +If the problem persists please check out our GitHub page [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D) ### Utils @@ -56,7 +56,7 @@ If the problem persists please check out our GitHub page [Submit issue](https:// | cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | | cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | -> Windows platform we will release later, if there is a need please [Submit Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 +> Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) ### TestNet @@ -166,7 +166,7 @@ Output: wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c -You can get the test PTC here with the wallet address obtained above: \[Request PTC\] (https://testnet.covenantsql.io/). +You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). After up to 2 minutes, you can use the cql command line tool to check the balance: From 13dda6f43d43f24139cbb4c376dca67837bab4d6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:31 +0800 Subject: [PATCH 256/421] New translations qna.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/qna.md | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md index 32cbd94..97404c0 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/qna.md +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -3,7 +3,28 @@ id: version-0.5.0-qna title: Q&A original_id: qna --- -## TBD +## Frequently Asked -- CQL 的数据库安全是如何做的,怎么防止 51% 攻击? -- CQL 是如何存储数据库的数据的? \ No newline at end of file +- **Q:** CQL 的数据库安全是如何做的? + + **A:** 不同于传统的数据库,CQL 是运行在开放互联网上的分布式数据库系统。安全方面主要做了如下的工作: + + 1. 密钥体系:CQL 使用 Bitcoin 的 `scep256k1` 曲线的非对称加密算法产生的公私钥对。 + 2. 网络通信:参见 [网络安全](./arch_network)。 + 3. 数据库权限: + +- **Q:** CQL 数据如果是不可篡改的,如何处理数据删除的需求? + + **A:** d + +- **Q:** CQL 是如何存储数据库的数据的? + + **A:** d + +- **Q:** CQL 支持数据量的上限大致是多少? + + **A:** d + +- **Q:** CQL 的数据存储如何计费、收费? + + **A:** d \ No newline at end of file From 8d317051c7006f0c715258eabc52bee7ca941dd8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:15:36 +0800 Subject: [PATCH 257/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quickstart.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index a4d1183..987d1c6 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -46,7 +46,7 @@ sudo chmod a+x /usr/local/bin/cql* # Fix Permission sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH ``` -If the problem persists please check out our GitHub page [Submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)。 +If the problem persists please check out our GitHub page [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D) ### Utils @@ -57,7 +57,7 @@ If the problem persists please check out our GitHub page [Submit issue](https:// | cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | | cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | -> Windows platform we will release later, if there is a need please [Submit Issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) 讨论。 +> Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) ### TestNet @@ -167,7 +167,7 @@ Output: wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c -You can get the test PTC here with the wallet address obtained above: \[Request PTC\] (https://testnet.covenantsql.io/). +You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). After up to 2 minutes, you can use the cql command line tool to check the balance: From 7b5c274a573996a27795f7d78058941a0a343c2a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:26:15 +0800 Subject: [PATCH 258/421] New translations arch_network.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch_network.md | 279 ++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 website/translated_docs/zh-CN/arch_network.md diff --git a/website/translated_docs/zh-CN/arch_network.md b/website/translated_docs/zh-CN/arch_network.md new file mode 100644 index 0000000..1bbe033 --- /dev/null +++ b/website/translated_docs/zh-CN/arch_network.md @@ -0,0 +1,279 @@ +--- +id: arch_network +title: RPC Framework +--- +The traditional key exchange like TLS or SSL needs a CA to ensure key exchange run safely. But in DH-RPC I use a DHT to do that. The main idea is removing CA Cert from the whole system by using a DHT for Naming and Key Exchange. + +DH-RPC is a secp256k1-ECDH-AES encrypted P2P RPC framework for decentralized applications written in golang. + +CovenantSQL is built on DH-RPC, including: + +- Byzantine Fault Tolerance consensus protocol [Kayak](https://godoc.org/github.com/CovenantSQL/CovenantSQL/kayak) +- Consistent Secure DHT +- DB API +- Metric Collect +- Blocks sync + +## Usage + +![](https://cdn.jsdelivr.net/gh/CovenantSQL/CovenantSQL@cc4aa933d80a5d31738081d13c7b1587ad47cffb/logo/dh-rpc.svg) + +Alice Client: + +```go +// Init Key Management System +route.InitKMS(PubKeyStoreFile) + +// Register Node public key, addr to Tracker +reqA := &proto.PingReq{ + Node: AliceNode, +} +respA := new(proto.PingResp) +rpc.NewCaller().CallNode(Tracker.NodeID, "DHT.Ping", reqA, respA) + +pc := rpc.NewPersistentCaller(BobNodeID) +respSimple := new(string) +pc.Call("Test.Talk", "Hi there", respSimple) +fmt.Printf("Response msg: %s", *respSimple) +``` + +Bob Server: + +```go +// RPC logic +// TestService to be register to RPC server +type TestService struct {} + +func (s *TestService) Talk(msg string, ret *string) error { + fmt.Println(msg) + resp := fmt.Sprintf("got msg %s", msg) + *ret = resp + return nil +} + +// Init Key Management System +route.InitKMS(PubKeyStoreFile) + +// Register DHT service +server, err := rpc.NewServerWithService(rpc.ServiceMap{ + "Test": &TestService{}, +}) + +// Init RPC server with an empty master key, which is not recommend +server.InitRPCServer("0.0.0.0:2120", PrivateKeyFile, "") + +// Start Node RPC server +server.Serve() +``` + +Tracker stuff can refer to the Example section below + +## Features + +- 100% compatible with Go [net/rpc](https://golang.org/pkg/net/rpc/) standard. +- ID based routing and Key exchange built on Secure Enhanced DHT. +- use MessagePack for serialization which support most types without writing `Marshal` and `Unmarshal`. +- Crypto Schema + - Use Elliptic Curve Secp256k1 for Asymmetric Encryption + - ECDH for Key Exchange + - PKCS#7 for padding + - AES-256-CFB for Symmetric Encryption + - Private key protected by master key + - Anonymous connection is also supported +- DHT persistence layer has 2 implementations: + - SQLite3 based simple traditional DHT + - [Kayak](https://godoc.org/github.com/CovenantSQL/CovenantSQL/kayak) based 2PC strong consistent DHT +- Connection pool based on [smux](https://github.com/xtaci/smux), make thousands of connections multiplexed over **One TCP connection**. + +## Stack + +[DH-RPC](rpc/) := TLS - Cert + DHT + +| Layer | Implementation | +|:------------------ |:------------------------------------------------------------------------------------------------------------:| +| RPC | `net/rpc` | +| Naming | [**C**onsistent **S**ecure **DHT**](https://godoc.org/github.com/CovenantSQL/CovenantSQL/consistent) | +| Pooling | Session Pool | +| Multiplex | [smux](https://github.com/xtaci/smux) | +| Transport Security | [**E**nhanced **TLS**](https://github.com/CovenantSQL/research/wiki/ETLS(Enhanced-Transport-Layer-Security)) | +| Network | TCP or KCP for optional later | + +## How it works + +As we all know, Elliptic Curve Public Key is computed form Private Key + +```go +ECPubKey := ECPrivKey.Pub() +``` + +DH-RPC node is generated by hash of NodePublicKey and an [Uint256 Nonce](../pow/cpuminer/uint256.go): + +```go +NodeID := sha256(blake2b-512(NodePublicKey + Uint256Nonce)) +``` + +DHT is used to hold the `NodeID`:`PublicKey` `NodeID`:`Addr` map. A RPC connection will do ECDH to get shared secret after TCP connection established. + +```go +GenECDHSharedSecret(APub, BPriv) == GenECDHSharedSecret(BPub, APriv) +``` + +The main procedure is described as sequence chart below: + + + +So anyone tries to fake NodeB by overwriting the address or public key on DHT without the private key of NodeB will be failed to get the correct shared secret. + +## Example + +The example below is 1 tracker and 2 nodes. + +Complete code can be found [here](_example/) + +#### Tracker Code + +```go +package main + +import ( + "os" + + "github.com/CovenantSQL/CovenantSQL/conf" + "github.com/CovenantSQL/CovenantSQL/consistent" + "github.com/CovenantSQL/CovenantSQL/route" + "github.com/CovenantSQL/CovenantSQL/rpc" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + //log.SetLevel(log.DebugLevel) + conf.GConf, _ = conf.LoadConfig(os.Args[1]) + log.Debugf("GConf: %#v", conf.GConf) + + // Init Key Management System + route.InitKMS(conf.GConf.PubKeyStoreFile) + + // Creating DHT RPC with simple persistence layer + dht, err := route.NewDHTService(conf.GConf.DHTFileName, new(consistent.KMSStorage), true) + if err != nil { + log.Fatalf("init dht failed: %v", err) + } + + // Register DHT service + server, err := rpc.NewServerWithService(rpc.ServiceMap{route.DHTRPCName: dht}) + if err != nil { + log.Fatal(err) + } + + // Init RPC server with an empty master key, which is not recommend + addr := conf.GConf.ListenAddr + masterKey := []byte("") + server.InitRPCServer(addr, conf.GConf.PrivateKeyFile, masterKey) + server.Serve() +} +``` + +#### Node Code + +```go +package main + +import ( + "bufio" + "fmt" + "os" + "strings" + + "github.com/CovenantSQL/CovenantSQL/conf" + "github.com/CovenantSQL/CovenantSQL/proto" + "github.com/CovenantSQL/CovenantSQL/route" + "github.com/CovenantSQL/CovenantSQL/rpc" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +// TestService to be register to RPC server +type TestService struct { +} + +func NewTestService() *TestService { + return &TestService{} +} + +func (s *TestService) Talk(msg string, ret *string) error { + fmt.Println(msg) + resp := fmt.Sprintf("got %s", msg) + *ret = resp + return nil +} + +func main() { + //log.SetLevel(log.DebugLevel) + conf.GConf, _ = conf.LoadConfig(os.Args[1]) + log.Debugf("GConf: %#v", conf.GConf) + + // Init Key Management System + route.InitKMS(conf.GConf.PubKeyStoreFile) + + // Register DHT service + server, err := rpc.NewServerWithService(rpc.ServiceMap{ + "Test": NewTestService(), + }) + if err != nil { + log.Fatal(err) + } + + // Init RPC server with an empty master key, which is not recommend + addr := conf.GConf.ListenAddr + masterKey := []byte("") + server.InitRPCServer(addr, conf.GConf.PrivateKeyFile, masterKey) + + // Start Node RPC server + go server.Serve() + + // Register Node public key, addr to Tracker(BP) + for _, n := range conf.GConf.KnownNodes { + client := rpc.NewCaller() + reqA := &proto.PingReq{ + Node: n, + } + respA := new(proto.PingResp) + err = client.CallNode(conf.GConf.BP.NodeID, "DHT.Ping", reqA, respA) + if err != nil { + log.Fatal(err) + } + log.Debugf("respA: %v", respA) + } + + // Read target node and connect to it + scanner := bufio.NewScanner(os.Stdin) + fmt.Print("Input target node ID: ") + scanner.Scan() + if scanner.Err() == nil { + target := proto.NodeID(strings.TrimSpace(scanner.Text())) + pc := rpc.NewPersistentCaller(target) + log.Debugf("connecting to %s", scanner.Text()) + + fmt.Print("Input msg: ") + for scanner.Scan() { + input := scanner.Text() + log.Debugf("get input %s", input) + repSimple := new(string) + err = pc.Call("Test.Talk", input, repSimple) + if err != nil { + log.Fatal(err) + } + log.Infof("resp msg: %s", *repSimple) + } + } +} +``` + +Start tracker and node1, node2 + +```bash +$ ./runTracker.sh & +$ ./runNode2.sh & +$ ./runNode1.sh +$ Input target node ID: 000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade #node2 +$ Input msg: abcdefg +``` \ No newline at end of file From 6660bec8d55a010293e67b326ef8dcf40b88fc9e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 22 Apr 2019 18:26:16 +0800 Subject: [PATCH 259/421] New translations arch_network.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/arch_network.md | 280 ++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/arch_network.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch_network.md b/website/translated_docs/zh-CN/version-0.5.0/arch_network.md new file mode 100644 index 0000000..66fcf1c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/arch_network.md @@ -0,0 +1,280 @@ +--- +id: version-0.5.0-arch_network +title: RPC Framework +original_id: arch_network +--- +The traditional key exchange like TLS or SSL needs a CA to ensure key exchange run safely. But in DH-RPC I use a DHT to do that. The main idea is removing CA Cert from the whole system by using a DHT for Naming and Key Exchange. + +DH-RPC is a secp256k1-ECDH-AES encrypted P2P RPC framework for decentralized applications written in golang. + +CovenantSQL is built on DH-RPC, including: + +- Byzantine Fault Tolerance consensus protocol [Kayak](https://godoc.org/github.com/CovenantSQL/CovenantSQL/kayak) +- Consistent Secure DHT +- DB API +- Metric Collect +- Blocks sync + +## Usage + +![](https://cdn.jsdelivr.net/gh/CovenantSQL/CovenantSQL@cc4aa933d80a5d31738081d13c7b1587ad47cffb/logo/dh-rpc.svg) + +Alice Client: + +```go +// Init Key Management System +route.InitKMS(PubKeyStoreFile) + +// Register Node public key, addr to Tracker +reqA := &proto.PingReq{ + Node: AliceNode, +} +respA := new(proto.PingResp) +rpc.NewCaller().CallNode(Tracker.NodeID, "DHT.Ping", reqA, respA) + +pc := rpc.NewPersistentCaller(BobNodeID) +respSimple := new(string) +pc.Call("Test.Talk", "Hi there", respSimple) +fmt.Printf("Response msg: %s", *respSimple) +``` + +Bob Server: + +```go +// RPC logic +// TestService to be register to RPC server +type TestService struct {} + +func (s *TestService) Talk(msg string, ret *string) error { + fmt.Println(msg) + resp := fmt.Sprintf("got msg %s", msg) + *ret = resp + return nil +} + +// Init Key Management System +route.InitKMS(PubKeyStoreFile) + +// Register DHT service +server, err := rpc.NewServerWithService(rpc.ServiceMap{ + "Test": &TestService{}, +}) + +// Init RPC server with an empty master key, which is not recommend +server.InitRPCServer("0.0.0.0:2120", PrivateKeyFile, "") + +// Start Node RPC server +server.Serve() +``` + +Tracker stuff can refer to the Example section below + +## Features + +- 100% compatible with Go [net/rpc](https://golang.org/pkg/net/rpc/) standard. +- ID based routing and Key exchange built on Secure Enhanced DHT. +- use MessagePack for serialization which support most types without writing `Marshal` and `Unmarshal`. +- Crypto Schema + - Use Elliptic Curve Secp256k1 for Asymmetric Encryption + - ECDH for Key Exchange + - PKCS#7 for padding + - AES-256-CFB for Symmetric Encryption + - Private key protected by master key + - Anonymous connection is also supported +- DHT persistence layer has 2 implementations: + - SQLite3 based simple traditional DHT + - [Kayak](https://godoc.org/github.com/CovenantSQL/CovenantSQL/kayak) based 2PC strong consistent DHT +- Connection pool based on [smux](https://github.com/xtaci/smux), make thousands of connections multiplexed over **One TCP connection**. + +## Stack + +[DH-RPC](rpc/) := TLS - Cert + DHT + +| Layer | Implementation | +|:------------------ |:------------------------------------------------------------------------------------------------------------:| +| RPC | `net/rpc` | +| Naming | [**C**onsistent **S**ecure **DHT**](https://godoc.org/github.com/CovenantSQL/CovenantSQL/consistent) | +| Pooling | Session Pool | +| Multiplex | [smux](https://github.com/xtaci/smux) | +| Transport Security | [**E**nhanced **TLS**](https://github.com/CovenantSQL/research/wiki/ETLS(Enhanced-Transport-Layer-Security)) | +| Network | TCP or KCP for optional later | + +## How it works + +As we all know, Elliptic Curve Public Key is computed form Private Key + +```go +ECPubKey := ECPrivKey.Pub() +``` + +DH-RPC node is generated by hash of NodePublicKey and an [Uint256 Nonce](../pow/cpuminer/uint256.go): + +```go +NodeID := sha256(blake2b-512(NodePublicKey + Uint256Nonce)) +``` + +DHT is used to hold the `NodeID`:`PublicKey` `NodeID`:`Addr` map. A RPC connection will do ECDH to get shared secret after TCP connection established. + +```go +GenECDHSharedSecret(APub, BPriv) == GenECDHSharedSecret(BPub, APriv) +``` + +The main procedure is described as sequence chart below: + + + +So anyone tries to fake NodeB by overwriting the address or public key on DHT without the private key of NodeB will be failed to get the correct shared secret. + +## Example + +The example below is 1 tracker and 2 nodes. + +Complete code can be found [here](_example/) + +#### Tracker Code + +```go +package main + +import ( + "os" + + "github.com/CovenantSQL/CovenantSQL/conf" + "github.com/CovenantSQL/CovenantSQL/consistent" + "github.com/CovenantSQL/CovenantSQL/route" + "github.com/CovenantSQL/CovenantSQL/rpc" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +func main() { + //log.SetLevel(log.DebugLevel) + conf.GConf, _ = conf.LoadConfig(os.Args[1]) + log.Debugf("GConf: %#v", conf.GConf) + + // Init Key Management System + route.InitKMS(conf.GConf.PubKeyStoreFile) + + // Creating DHT RPC with simple persistence layer + dht, err := route.NewDHTService(conf.GConf.DHTFileName, new(consistent.KMSStorage), true) + if err != nil { + log.Fatalf("init dht failed: %v", err) + } + + // Register DHT service + server, err := rpc.NewServerWithService(rpc.ServiceMap{route.DHTRPCName: dht}) + if err != nil { + log.Fatal(err) + } + + // Init RPC server with an empty master key, which is not recommend + addr := conf.GConf.ListenAddr + masterKey := []byte("") + server.InitRPCServer(addr, conf.GConf.PrivateKeyFile, masterKey) + server.Serve() +} +``` + +#### Node Code + +```go +package main + +import ( + "bufio" + "fmt" + "os" + "strings" + + "github.com/CovenantSQL/CovenantSQL/conf" + "github.com/CovenantSQL/CovenantSQL/proto" + "github.com/CovenantSQL/CovenantSQL/route" + "github.com/CovenantSQL/CovenantSQL/rpc" + "github.com/CovenantSQL/CovenantSQL/utils/log" +) + +// TestService to be register to RPC server +type TestService struct { +} + +func NewTestService() *TestService { + return &TestService{} +} + +func (s *TestService) Talk(msg string, ret *string) error { + fmt.Println(msg) + resp := fmt.Sprintf("got %s", msg) + *ret = resp + return nil +} + +func main() { + //log.SetLevel(log.DebugLevel) + conf.GConf, _ = conf.LoadConfig(os.Args[1]) + log.Debugf("GConf: %#v", conf.GConf) + + // Init Key Management System + route.InitKMS(conf.GConf.PubKeyStoreFile) + + // Register DHT service + server, err := rpc.NewServerWithService(rpc.ServiceMap{ + "Test": NewTestService(), + }) + if err != nil { + log.Fatal(err) + } + + // Init RPC server with an empty master key, which is not recommend + addr := conf.GConf.ListenAddr + masterKey := []byte("") + server.InitRPCServer(addr, conf.GConf.PrivateKeyFile, masterKey) + + // Start Node RPC server + go server.Serve() + + // Register Node public key, addr to Tracker(BP) + for _, n := range conf.GConf.KnownNodes { + client := rpc.NewCaller() + reqA := &proto.PingReq{ + Node: n, + } + respA := new(proto.PingResp) + err = client.CallNode(conf.GConf.BP.NodeID, "DHT.Ping", reqA, respA) + if err != nil { + log.Fatal(err) + } + log.Debugf("respA: %v", respA) + } + + // Read target node and connect to it + scanner := bufio.NewScanner(os.Stdin) + fmt.Print("Input target node ID: ") + scanner.Scan() + if scanner.Err() == nil { + target := proto.NodeID(strings.TrimSpace(scanner.Text())) + pc := rpc.NewPersistentCaller(target) + log.Debugf("connecting to %s", scanner.Text()) + + fmt.Print("Input msg: ") + for scanner.Scan() { + input := scanner.Text() + log.Debugf("get input %s", input) + repSimple := new(string) + err = pc.Call("Test.Talk", input, repSimple) + if err != nil { + log.Fatal(err) + } + log.Infof("resp msg: %s", *repSimple) + } + } +} +``` + +Start tracker and node1, node2 + +```bash +$ ./runTracker.sh & +$ ./runNode2.sh & +$ ./runNode1.sh +$ Input target node ID: 000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade #node2 +$ Input msg: abcdefg +``` \ No newline at end of file From 731bbd1375d592d225c81806b44411c4fb0e408e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:38 +0800 Subject: [PATCH 260/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_advance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_advance.md b/website/translated_docs/zh-CN/cql_advance.md index 81b24c2..4f9bdf8 100644 --- a/website/translated_docs/zh-CN/cql_advance.md +++ b/website/translated_docs/zh-CN/cql_advance.md @@ -6,9 +6,9 @@ Sub-command `rpc` calls the remote process directly in the CovenantSQL network. ## Sub-command `rpc` Complete Parameter - usage: cql rpc [parameter]... + usage: cql rpc [common params] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request - Rpc command make a RPC request to the target server + RPC makes a RPC request to the target endpoint. e.g. cql rpc -name 'MCC.QuerySQLChainProfile' \ -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ From 4565dad8ffa612a65dac762e4dbe090e3f2c31a2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:45 +0800 Subject: [PATCH 261/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md index 3a5e373..100b190 100644 --- a/website/translated_docs/zh-CN/cql_account.md +++ b/website/translated_docs/zh-CN/cql_account.md @@ -60,9 +60,9 @@ Output: Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. - usage: cql generate [parameter]... config | public + usage: cql generate [common params] config | public - Generate command can generate private.key and config.yaml for CovenantSQL. + Generate generates private.key and config.yaml for CovenantSQL. e.g. cql generate config @@ -102,9 +102,9 @@ Output: ## Sub-command `idminer` Complete Parameters - usage: cql idminer [parameter]... + usage: cql idminer [common params] [-difficulty number] [-loop [true]] - IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + IDMiner calculates legal node id and it's nonce. Default parameters are difficulty of 24 and no endless loop. e.g. cql idminer -difficulty 24 From b8fe07e76ac472a473447adf5be4e311aa5b5f06 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:46 +0800 Subject: [PATCH 262/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_access.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index 32f09d8..199c515 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -59,16 +59,16 @@ Here is an example of using the interactive console: The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. - usage: cql console [parameter]... + usage: cql console [common params] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] - Console command can run a interactive SQL console for CovenantSQL + Console runs an interactive SQL console for CovenantSQL. e.g. - cql console -dsn covenantsql://the_dsn_of_your_database + cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c There is also a -command param for SQL script, and a -file param for reading SQL in a file. If those params are set, it will run SQL script and exit without staying console mode. e.g. - cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c -command "create table test1(test2 int);" Params: -adapter string From f17d9e36dd51f76a9de8762cb39080e680b46d50 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:48 +0800 Subject: [PATCH 263/421] New translations cql_db_manage.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_manage.md | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index f61a740..8a0b614 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -133,24 +133,24 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `create` Complete Parameters - usage: cql create [parameter]... db_meta_json + usage: cql create [common params] [-wait-tx-confirm] db_meta_json - Create CovenantSQL database by database meta info JSON string, meta info must include node count. + Create creates a CovenantSQL database by database meta info JSON string. The meta info must include node count. e.g. - cql create '{"node":2}' - - A complete introduction of db_meta_json fields: - targetminers []string // List of target miner addresses - node int // Target node number - space int // Minimum disk space requirement, 0 for none - memory int // Minimum memory requirement, 0 for none - loadavgpercpu float // Minimum idle CPU requirement, 0 for none - encryptionkey string // Encryption key for persistence data - useeventualconsistency bool // Use eventual consistency to sync among miner nodes - consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency - isolationlevel int // Isolation level in a single node - - Since CovenantSQL is blockchain database, you may want get confirm of creation. + cql create '{"node": 2}' + + A complete introduction of db_meta_json fields: + target-miners []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + load-avg-per-cpu float // Minimum idle CPU requirement, 0 for none + encrypt-key string // Encryption key for persistence data + eventual-consistency bool // Use eventual consistency to sync among miner nodes + consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency + isolation-level int // Isolation level in a single node + + Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the creation takes effect. e.g. cql create -wait-tx-confirm '{"node": 2}' @@ -161,15 +161,15 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `drop` Complete Parameters - usage: cql drop [parameter]... dsn/dbid + usage: cql drop [common params] [-wait-tx-confirm] dsn/dbid - Drop command can drop a database by DSN or database id + Drop drops a CovenantSQL database by DSN or database ID. e.g. cql drop covenantsql://the_dsn_of_your_database - Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the drop operation takes effect. e.g. - cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c Params: -wait-tx-confirm @@ -178,13 +178,13 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `grant` Complete Parameters - usage: cql grant [parameter]... permission_meta_json + usage: cql grant [common params] [-wait-tx-confirm] permission_meta_json - Grant command can give a user some specific permissions on your database + Grant grants specific permissions for the target user. e.g. cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - Since CovenantSQL is blockchain database, you may want get confirm of permission update. + Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the permission takes effect. e.g. cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' From dd49e1f8062b82052f77ed6037fbb0b56d5a71bc Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:49 +0800 Subject: [PATCH 264/421] New translations cql_server.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_server.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_server.md b/website/translated_docs/zh-CN/cql_server.md index bdcf019..62c4e63 100644 --- a/website/translated_docs/zh-CN/cql_server.md +++ b/website/translated_docs/zh-CN/cql_server.md @@ -4,9 +4,9 @@ title: Local Servers --- ## Sub-command `explorer` Complete Parameter - usage: cql explorer [parameter]... address + usage: cql explorer [common params] [-tmp-path path] [-bg-log-level level] listen_address - Explorer command serves a SQLChain web explorer. + Explorer serves a SQLChain web explorer. e.g. cql explorer 127.0.0.1:8546 @@ -19,9 +19,9 @@ title: Local Servers ## Sub-command `mirror` Complete Parameter - usage: cql mirror [parameter]... dsn/dbid address + usage: cql mirror [common params] [-tmp-path path] [-bg-log-level level] dsn listen_address - Mirror command subscribes database updates and serves a read-only database mirror. + Mirror subscribes database updates and serves a read-only database mirror. e.g. cql mirror database_id 127.0.0.1:9389 @@ -36,9 +36,9 @@ title: Local Servers See for details of adapter server. - usage: cql adapter [parameter]... address + usage: cql adapter [common params] [-tmp-path path] [-bg-log-level level] [-mirror addr] listen_address - Adapter command serves a SQLChain adapter + Adapter serves a SQLChain adapter. e.g. cql adapter 127.0.0.1:7784 From 40af1a1ad1589cc9ee499ec85d86357064d3bc82 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 12:54:50 +0800 Subject: [PATCH 265/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index ead0b10..e6a4d2c 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -82,9 +82,9 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `wallet` Complete Parameters - usage: cql wallet [parameter]... + usage: cql wallet [common params] [-balance type] - Wallet command can get CovenantSQL wallet address and the token balance of the current account + Wallet gets the CovenantSQL wallet address and the token balances of the current account. e.g. cql wallet @@ -98,16 +98,15 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `transfer` Complete Parameters - usage: cql transfer [parameter]... meta_json + usage: cql transfer [common params] [-wait-tx-confirm] meta_json - Transfer command can transfer your token to the target account. - The command argument is JSON meta info of a token transaction. + Transfer transfers your token to the target account. The command argument is a token transaction in JSON format. e.g. - cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + cql transfer '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' - Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the transfer takes effect. e.g. - cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + cql transfer -wait-tx-confirm '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' Params: -wait-tx-confirm From 9ad0139286a8cef1295ac00233bb39e727bc7b9b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 13:24:46 +0800 Subject: [PATCH 266/421] New translations cql_db_manage.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_manage.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index 8a0b614..d6ce542 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -150,7 +150,7 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency isolation-level int // Isolation level in a single node - Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the creation takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. e.g. cql create -wait-tx-confirm '{"node": 2}' @@ -167,7 +167,7 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio e.g. cql drop covenantsql://the_dsn_of_your_database - Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the drop operation takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect. e.g. cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c @@ -184,7 +184,7 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio e.g. cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the permission takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the permission takes effect. e.g. cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' From 699d318e5d9be1c100efcc9e025c1c08654298ad Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 13:24:48 +0800 Subject: [PATCH 267/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index e6a4d2c..9b7ea0a 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -104,7 +104,7 @@ Note that the above output message indicates that the transfer request is succes e.g. cql transfer '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' - Since CovenantSQL is built on top of blockchain, you may want to wait for the transaction confirmation before the transfer takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the transfer takes effect. e.g. cql transfer -wait-tx-confirm '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' From 4a2979be221845c45e621c421d09d31d8faa5c1f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 14:56:24 +0800 Subject: [PATCH 268/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_access.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index 199c515..990f2a0 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -20,7 +20,7 @@ Output: co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -Or access as `account2` if it has successfully been granted access permission: +Or access as `account2` if it has been granted access permission successfully: ```bash cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' From e7939dd29c36f5a6e48d8a2ae4215c5a8330bd0a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 14:56:26 +0800 Subject: [PATCH 269/421] New translations cql_db_manage.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_manage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index d6ce542..7663baf 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -165,7 +165,7 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio Drop drops a CovenantSQL database by DSN or database ID. e.g. - cql drop covenantsql://the_dsn_of_your_database + cql drop covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect. e.g. From eb53bc3c4228913a2a0bb27d3a39787c5986a07a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 14:56:27 +0800 Subject: [PATCH 270/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md index d5a2fef..ef17cc7 100644 --- a/website/translated_docs/zh-CN/cql_intro.md +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -9,7 +9,7 @@ CovenantSQL provides a `cql` command line toolset for terminal users to access a The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: - `private.key`:a private key file which is generated while creating an account, be sure to keep it safe -- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment](deployment)) For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. From 0d30a47c53fc0c12774520d875abfd86a2cbe14e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 14:56:28 +0800 Subject: [PATCH 271/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index 9b7ea0a..75f2c80 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -54,7 +54,7 @@ Output: ## Transferring Tokens to Another Account -Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: +Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: ```json { From 3b9c97629e0ff311a067a95e450cfbc774c73578 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:13 +0800 Subject: [PATCH 272/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/intro.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/intro.md b/website/translated_docs/zh-CN/intro.md index 5a76c76..fb1f732 100644 --- a/website/translated_docs/zh-CN/intro.md +++ b/website/translated_docs/zh-CN/intro.md @@ -3,7 +3,6 @@ id: intro title: CovenantSQL Intro --- -

@@ -29,7 +28,7 @@ title: CovenantSQL Intro alt="homebrew">

-CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: +CovenantSQL(CQL) is a decentralized, GDPR-compliant, trusted, SQL database with blockchain features: - **ServerLess**: Free, High Availabile, Auto Sync Database Service for Serverless App - **GDPR-compliant**: Zero pain to be GDPR-compliant. From e21967a8299f838c6949dee80540952f090bc522 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:18 +0800 Subject: [PATCH 273/421] New translations quandl.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quandl.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quandl.md b/website/translated_docs/zh-CN/version-0.5.0/quandl.md index 3608e74..246b98a 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quandl.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quandl.md @@ -3,6 +3,7 @@ id: version-0.5.0-quandl title: 基于 Quandl 的金融数据分析 original_id: quandl --- + ## 关于 Quandl Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 From 1a7698b15243f8b4fb1c1486c02731ccb4225270 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:19 +0800 Subject: [PATCH 274/421] New translations deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/deployment.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment.md b/website/translated_docs/zh-CN/version-0.5.0/deployment.md index dc52541..64da004 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment.md @@ -3,6 +3,7 @@ id: version-0.5.0-deployment title: Docker Deploy original_id: deployment --- + ## Deploy with CovenantSQL Docker ### Install Docker From 55c70219048e0251963c00da2e748c8714211f74 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:21 +0800 Subject: [PATCH 275/421] New translations cql.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql.md b/website/translated_docs/zh-CN/version-0.5.0/cql.md index 00ef48f..5c15d84 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql title: Client original_id: cql --- + ## Intro CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). From b6ed259a6b902ffd6407fe19b13507b3cc676c88 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:22 +0800 Subject: [PATCH 276/421] New translations qna.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/qna.md | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md index 97404c0..9ea15e1 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/qna.md +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -3,28 +3,7 @@ id: version-0.5.0-qna title: Q&A original_id: qna --- -## Frequently Asked - -- **Q:** CQL 的数据库安全是如何做的? - - **A:** 不同于传统的数据库,CQL 是运行在开放互联网上的分布式数据库系统。安全方面主要做了如下的工作: - - 1. 密钥体系:CQL 使用 Bitcoin 的 `scep256k1` 曲线的非对称加密算法产生的公私钥对。 - 2. 网络通信:参见 [网络安全](./arch_network)。 - 3. 数据库权限: - -- **Q:** CQL 数据如果是不可篡改的,如何处理数据删除的需求? - - **A:** d -- **Q:** CQL 是如何存储数据库的数据的? - - **A:** d - -- **Q:** CQL 支持数据量的上限大致是多少? - - **A:** d +## Frequently Asked -- **Q:** CQL 的数据存储如何计费、收费? - - **A:** d \ No newline at end of file +- \ No newline at end of file From ac3e692d14f963159bba748783749f11e57f2015 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:24 +0800 Subject: [PATCH 277/421] New translations guide-zh.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md index 005ca3d..a5bdb48 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-guide-zh title: 快速开始 original_id: guide-zh --- + ## 下载 CovenantSQL 工具包 请 [下载最新版 CovenantSQL 工具包](https://github.com/CovenantSQL/CovenantSQL/releases)。您将得到以下命令行工具:`cql`、`cql-utils`。 From 72c5c25fd9f15bc952f23fa0492a438b185c0a76 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:26 +0800 Subject: [PATCH 278/421] New translations api-json-rpc.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md b/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md index 1038b09..2935ee1 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/api-json-rpc.md @@ -3,6 +3,7 @@ id: version-0.5.0-api-json-rpc title: JSON RPC original_id: api-json-rpc --- + > JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. CovenantSQL provides a suite of RPC methods in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) for easily accessing to CovenantSQL networks. From 1212ae628bb25d5114adb52070a87b25c810c3df Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:28 +0800 Subject: [PATCH 279/421] New translations development-golang-client-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/development-golang-client-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md index 12dd894..45ec3f0 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-golang-client-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-golang-client title: 使用 Golang 驱动访问数据库 original_id: golang-client --- + 本文档介绍 CovenantSQL 客户端的使用方式。客户端用来创建、查询、更新和删除 SQLChain 以及绑定的数据库。 ## 开始之前 From b694412e4d3d2745e17460a0475f8f3087101e04 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:31 +0800 Subject: [PATCH 280/421] New translations getting-started-overview-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/getting-started-overview-zh.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md index 956b8e5..75df5c6 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-overview-zh.md @@ -4,7 +4,6 @@ title: 简介 original_id: intro --- -

From 3261df12976876bd4dde7259ce3c31f013c896fc Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:32 +0800 Subject: [PATCH 281/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quickstart.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md index 987d1c6..f3009fa 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quickstart.md @@ -3,6 +3,8 @@ id: version-0.5.0-quickstart title: Quick Start original_id: quickstart --- + + ## CovenantSQL Client ### Install From 83278d73d2c449247633700fd1dccf5c1bbeeff2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:33 +0800 Subject: [PATCH 282/421] New translations development-cmd-cql-utils-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md index ebd52dd..619f261 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-utils-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-keygen title: 使用 cql-utils 生成密钥与钱包 original_id: keygen --- + `cql-utils` 是 CovenantSQL 的一个命令行工具,具体用法如下。 ## 安装 From ae4649eda678f607f0b59537e7052e8e684dcf15 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:35 +0800 Subject: [PATCH 283/421] New translations getting-started-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/getting-started-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md index 855ce18..398ad03 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-local-deployment title: CovenantSQL 综述 original_id: local-deployment --- + # CovenantSQL 介绍

From ef515095841205937e7045ccc486da840645fb3f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:37 +0800 Subject: [PATCH 284/421] New translations getting-started-testnet-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md index 78629bb..80988af 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-testnet-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-testnet title: CovenantSQL 测试网快速入门 original_id: testnet --- + [CovenantSQL](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md) 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点: 1. **SQL**: 支持 SQL-92 标准 From bf49cf359a52afa46e6a0f111d5b28eb3ab63a17 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:38 +0800 Subject: [PATCH 285/421] New translations arch.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/arch.md b/website/translated_docs/zh-CN/arch.md index 5611d55..cfbe9dd 100644 --- a/website/translated_docs/zh-CN/arch.md +++ b/website/translated_docs/zh-CN/arch.md @@ -2,6 +2,7 @@ id: arch title: Architecture --- + ## 3 Layers Arch ![CovenantSQL 3 Layer design](https://github.com/CovenantSQL/CovenantSQL/raw/ed2878359345cd86e4221f14cd59e4654361b64e/logo/arch.png) From 2989c43ff8eea5ac523a7dc84b7937c35e267833 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:40 +0800 Subject: [PATCH 286/421] New translations arch_network.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch_network.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/arch_network.md b/website/translated_docs/zh-CN/arch_network.md index 1bbe033..171e2d7 100644 --- a/website/translated_docs/zh-CN/arch_network.md +++ b/website/translated_docs/zh-CN/arch_network.md @@ -2,6 +2,7 @@ id: arch_network title: RPC Framework --- + The traditional key exchange like TLS or SSL needs a CA to ensure key exchange run safely. But in DH-RPC I use a DHT to do that. The main idea is removing CA Cert from the whole system by using a DHT for Naming and Key Exchange. DH-RPC is a secp256k1-ECDH-AES encrypted P2P RPC framework for decentralized applications written in golang. From 7d48ec58d5eaf12faa684a9c2e48f03f342dd88a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:41 +0800 Subject: [PATCH 287/421] New translations usecase.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/usecase.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase.md b/website/translated_docs/zh-CN/version-0.5.0/usecase.md index fedfbe6..e0ab7d4 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase.md @@ -3,6 +3,7 @@ id: version-0.5.0-usecase title: Use case original_id: usecase --- + ## Traditional App ### Privacy data From 8f4dfcd347e69a79a2361103e0ea8a7e4bb3caf8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:42 +0800 Subject: [PATCH 288/421] New translations development-cmd-cql-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md index a89f54d..fe17f21 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/development-cmd-cql-zh.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql title: 使用命令行客户端 cql 创建数据库 original_id: cql --- + 本文档主要介绍 CovenantSQL 命令行客户端 `cql` 的使用。`cql` 是一个用于批量进行 SQLChain 上数据库的创建、查询、更新或删除操作的命令行工具。 ## 安装 From b92b7f6bf95faa69d264eb434457283f2a641c95 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:44 +0800 Subject: [PATCH 289/421] New translations intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/intro.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/intro.md b/website/translated_docs/zh-CN/version-0.5.0/intro.md index c340974..af0db85 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/intro.md @@ -4,7 +4,6 @@ title: CovenantSQL Intro original_id: intro --- -

@@ -30,7 +29,7 @@ original_id: intro alt="homebrew">

-CovenantSQL(CQL) is a GDPR-compliant SQL database running on Open Internet without central coordination: +CovenantSQL(CQL) is a decentralized, GDPR-compliant, trusted, SQL database with blockchain features: - **ServerLess**: Free, High Availabile, Auto Sync Database Service for Serverless App - **GDPR-compliant**: Zero pain to be GDPR-compliant. From f662d7da76a25d201430b4c3a5cc3f8dc3d40316 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:45 +0800 Subject: [PATCH 290/421] New translations usecase_dapp.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase_dapp.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/usecase_dapp.md b/website/translated_docs/zh-CN/usecase_dapp.md index 4da8c66..777b2d0 100644 --- a/website/translated_docs/zh-CN/usecase_dapp.md +++ b/website/translated_docs/zh-CN/usecase_dapp.md @@ -2,4 +2,5 @@ id: usecase_dapp title: DApp --- + Storing data on Bitcoin or Ethereum is quite expensive ($4305 / MB on Ethereum 2018-05-15). Programming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world. \ No newline at end of file From 31bdf28972a59aa5e07f2b4a89505e7543f2b1a5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:47 +0800 Subject: [PATCH 291/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 69b40e6..10ef58a 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -2,6 +2,8 @@ id: quickstart title: Quick Start --- + + ## CovenantSQL Client ### Install From a97ab18e4d95cd0fc467173c59b42f7623e50bc6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:48 +0800 Subject: [PATCH 292/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md index 0d34692..2e053d8 100644 --- a/website/translated_docs/zh-CN/qna.md +++ b/website/translated_docs/zh-CN/qna.md @@ -2,28 +2,7 @@ id: qna title: Q&A --- -## Frequently Asked - -- **Q:** CQL 的数据库安全是如何做的? - - **A:** 不同于传统的数据库,CQL 是运行在开放互联网上的分布式数据库系统。安全方面主要做了如下的工作: - - 1. 密钥体系:CQL 使用 Bitcoin 的 `scep256k1` 曲线的非对称加密算法产生的公私钥对。 - 2. 网络通信:参见 [网络安全](./arch_network)。 - 3. 数据库权限: - -- **Q:** CQL 数据如果是不可篡改的,如何处理数据删除的需求? - - **A:** d -- **Q:** CQL 是如何存储数据库的数据的? - - **A:** d - -- **Q:** CQL 支持数据量的上限大致是多少? - - **A:** d +## Frequently Asked -- **Q:** CQL 的数据存储如何计费、收费? - - **A:** d \ No newline at end of file +- \ No newline at end of file From c2a2bffbdfb2ce1cf76955b36c797ff5b9e25a73 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:50 +0800 Subject: [PATCH 293/421] New translations nav.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/nav.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/nav.md b/website/translated_docs/zh-CN/version-0.5.0/nav.md index 5c472bd..b2cbc94 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/nav.md +++ b/website/translated_docs/zh-CN/version-0.5.0/nav.md @@ -3,6 +3,7 @@ id: version-0.5.0-nav title: 使用导航 original_id: nav --- + ## 快速开始 [TestNet 快速开始](./quickstart) From 8da996de56b6379292c5d8578879297be0648f13 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:51 +0800 Subject: [PATCH 294/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_js.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/driver_js.md b/website/translated_docs/zh-CN/driver_js.md index 7f03e57..469aeb5 100644 --- a/website/translated_docs/zh-CN/driver_js.md +++ b/website/translated_docs/zh-CN/driver_js.md @@ -2,6 +2,7 @@ id: driver_js title: JavaScript --- + ## Use JavaScript to access CovenantSQL Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). From 2a4ed32de53a37be378917913154af81b5e21aaa Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:53 +0800 Subject: [PATCH 295/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_golang.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/driver_golang.md b/website/translated_docs/zh-CN/driver_golang.md index e1fec93..3bb7fca 100644 --- a/website/translated_docs/zh-CN/driver_golang.md +++ b/website/translated_docs/zh-CN/driver_golang.md @@ -2,6 +2,7 @@ id: driver_golang title: Golang --- + ## Use Golang to access CovenantSQL `CovenantSQL` provides `Golang SDK` to access database using native rpc protocol. The `cql` tool is developed based on `Golang SDK`. From d10d1605000de3ad701d506bc40fc0de26186b61 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:54 +0800 Subject: [PATCH 296/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index d7c12c9..a0f8e81 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -2,6 +2,7 @@ id: adapter title: Adapter --- + # Use Adapter to access CovenantSQL `CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. From 163f47a98ae4500c162297450f912983b7afcf8d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:55 +0800 Subject: [PATCH 297/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_python.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md index 62f739b..7fb17e3 100644 --- a/website/translated_docs/zh-CN/driver_python.md +++ b/website/translated_docs/zh-CN/driver_python.md @@ -2,6 +2,7 @@ id: driver_python title: Python --- + ## Use Python to access CovenantSQL Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). From 75c725c2d8bf1d061d483fdbf20ac8855dcc0fee Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:57 +0800 Subject: [PATCH 298/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 27d0176..2e48080 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -2,6 +2,7 @@ id: driver_java title: Java --- + ## Use Java to access CovenantSQL `CovenantSQL` provides `Java SDK` to access database instance through [`Adapter`](./adapter) service. From bad139297d9158b4e8d2ae8369c0e58a103f128f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:42:58 +0800 Subject: [PATCH 299/421] New translations usecase_traditional_app.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase_traditional_app.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/usecase_traditional_app.md b/website/translated_docs/zh-CN/usecase_traditional_app.md index a637d52..cbd0655 100644 --- a/website/translated_docs/zh-CN/usecase_traditional_app.md +++ b/website/translated_docs/zh-CN/usecase_traditional_app.md @@ -2,6 +2,7 @@ id: usecase_traditional_app title: Traditional App --- + ## Privacy data If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: From 3988ef38959ccfd853425310bd373cf4dbe9b577 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:03 +0800 Subject: [PATCH 300/421] New translations usecase_data_analysis.md (Chinese Simplified) --- website/translated_docs/zh-CN/usecase_data_analysis.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/usecase_data_analysis.md b/website/translated_docs/zh-CN/usecase_data_analysis.md index 0569201..4b95703 100644 --- a/website/translated_docs/zh-CN/usecase_data_analysis.md +++ b/website/translated_docs/zh-CN/usecase_data_analysis.md @@ -2,6 +2,7 @@ id: usecase_data_analysis title: Data Analysis --- + ## 关于 Quandl Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 From 864edc1a96263a39a65d9ece25d5481c1f2ccb33 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:04 +0800 Subject: [PATCH 301/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md index 100b190..dfe35d3 100644 --- a/website/translated_docs/zh-CN/cql_account.md +++ b/website/translated_docs/zh-CN/cql_account.md @@ -2,6 +2,7 @@ id: cql_account title: Account Management --- + For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. ## Creating New Account From 20c29f446e039f94c212ba40d260e4778419317b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:08 +0800 Subject: [PATCH 302/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_advance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_advance.md b/website/translated_docs/zh-CN/cql_advance.md index 4f9bdf8..210c8c0 100644 --- a/website/translated_docs/zh-CN/cql_advance.md +++ b/website/translated_docs/zh-CN/cql_advance.md @@ -2,6 +2,7 @@ id: cql_advance title: Advanced Usage --- + Sub-command `rpc` calls the remote process directly in the CovenantSQL network. ## Sub-command `rpc` Complete Parameter From 348837674101092e8914e8384f31c6bab4a3f882 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:09 +0800 Subject: [PATCH 303/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_access.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index 990f2a0..e6825b4 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -2,6 +2,7 @@ id: cql_db_access title: Accessing Database --- + Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: ```bash From e8c3f4b2edae55265ce0fc68046da0f852562649 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:12 +0800 Subject: [PATCH 304/421] New translations cql_db_manage.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_manage.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index 7663baf..8a0b220 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -2,6 +2,7 @@ id: cql_db_manage title: Database Management --- + ## Creating Database Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: From 6768ee284d8e0867999e55e402cbe40bc6a5de26 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:13 +0800 Subject: [PATCH 305/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md index ef17cc7..9649402 100644 --- a/website/translated_docs/zh-CN/cql_intro.md +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -2,6 +2,7 @@ id: cql_intro title: Overview --- + CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). ## Private Key and Config File From 4ad14cac64811600a0273be9fb5ddaea90ed3465 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:17 +0800 Subject: [PATCH 306/421] New translations cql_server.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_server.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_server.md b/website/translated_docs/zh-CN/cql_server.md index 62c4e63..6d42cd6 100644 --- a/website/translated_docs/zh-CN/cql_server.md +++ b/website/translated_docs/zh-CN/cql_server.md @@ -2,6 +2,7 @@ id: cql_server title: Local Servers --- + ## Sub-command `explorer` Complete Parameter usage: cql explorer [common params] [-tmp-path path] [-bg-log-level level] listen_address From 6137a367edb365b4dcc2264b5d9b85d991506c64 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:18 +0800 Subject: [PATCH 307/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index 75f2c80..f25fd5e 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -2,6 +2,7 @@ id: cql_wallet title: Wallet Management --- + ## Wallet Address Once the private key and config file is set, you can use sub-command `wallet` to check the wallet address of the account: From 89390b1ae072728af28247d23b113e4961de91d9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:19 +0800 Subject: [PATCH 308/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql_intro.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md index e760433..903832d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_intro.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql_intro title: Overview original_id: cql_intro --- + CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). ## Private Key and Config File @@ -10,7 +11,7 @@ CovenantSQL provides a `cql` command line toolset for terminal users to access a The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: - `private.key`:a private key file which is generated while creating an account, be sure to keep it safe -- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment by One Click](deployment)) +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment](deployment)) For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. From c844bd3b49c11f5e21774dfc56c08adaa59c43e3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:21 +0800 Subject: [PATCH 309/421] New translations arch_network.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/arch_network.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch_network.md b/website/translated_docs/zh-CN/version-0.5.0/arch_network.md index 66fcf1c..56a7d28 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/arch_network.md +++ b/website/translated_docs/zh-CN/version-0.5.0/arch_network.md @@ -3,6 +3,7 @@ id: version-0.5.0-arch_network title: RPC Framework original_id: arch_network --- + The traditional key exchange like TLS or SSL needs a CA to ensure key exchange run safely. But in DH-RPC I use a DHT to do that. The main idea is removing CA Cert from the whole system by using a DHT for Naming and Key Exchange. DH-RPC is a secp256k1-ECDH-AES encrypted P2P RPC framework for decentralized applications written in golang. From 799ca0e563aa3770959627bb65e3ee330768c647 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:23 +0800 Subject: [PATCH 310/421] New translations arch.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/arch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch.md b/website/translated_docs/zh-CN/version-0.5.0/arch.md index f752e12..44a29b1 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/arch.md +++ b/website/translated_docs/zh-CN/version-0.5.0/arch.md @@ -3,6 +3,7 @@ id: version-0.5.0-arch title: Architecture original_id: arch --- + ## 3 Layers Arch ![CovenantSQL 3 Layer design](https://github.com/CovenantSQL/CovenantSQL/raw/ed2878359345cd86e4221f14cd59e4654361b64e/logo/arch.png) From 19d27b028688d5e0018458cf938d85ff2cc9535c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:24 +0800 Subject: [PATCH 311/421] New translations cql_wallet.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_wallet.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md b/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md index 51f986c..a09de46 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_wallet.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql_wallet title: Wallet Management original_id: cql_wallet --- + ## Wallet Address Once the private key and config file is set, you can use sub-command `wallet` to check the wallet address of the account: @@ -55,7 +56,7 @@ Output: ## Transferring Tokens to Another Account -Once you get tokens from [TestNet](quickstart) or [Docker Environment by One-Click](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: +Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: ```json { @@ -83,9 +84,9 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `wallet` Complete Parameters - usage: cql wallet [parameter]... + usage: cql wallet [common params] [-balance type] - Wallet command can get CovenantSQL wallet address and the token balance of the current account + Wallet gets the CovenantSQL wallet address and the token balances of the current account. e.g. cql wallet @@ -99,16 +100,15 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `transfer` Complete Parameters - usage: cql transfer [parameter]... meta_json + usage: cql transfer [common params] [-wait-tx-confirm] meta_json - Transfer command can transfer your token to the target account. - The command argument is JSON meta info of a token transaction. + Transfer transfers your token to the target account. The command argument is a token transaction in JSON format. e.g. - cql transfer '{"addr":"your_account_addr","amount":"100 Particle"}' + cql transfer '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' - Since CovenantSQL is based on blockchain, you may want to wait for the transaction confirmation. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the transfer takes effect. e.g. - cql transfer -wait-tx-confirm '{"addr":"your_account_addr","amount":"100 Particle"}' + cql transfer -wait-tx-confirm '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' Params: -wait-tx-confirm From df3eea647903ecd300527b12c4aedc3bc277499a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:26 +0800 Subject: [PATCH 312/421] New translations cql_server.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_server.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_server.md b/website/translated_docs/zh-CN/version-0.5.0/cql_server.md index b4d1546..d4bcf22 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_server.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_server.md @@ -3,11 +3,12 @@ id: version-0.5.0-cql_server title: Local Servers original_id: cql_server --- + ## Sub-command `explorer` Complete Parameter - usage: cql explorer [parameter]... address + usage: cql explorer [common params] [-tmp-path path] [-bg-log-level level] listen_address - Explorer command serves a SQLChain web explorer. + Explorer serves a SQLChain web explorer. e.g. cql explorer 127.0.0.1:8546 @@ -20,9 +21,9 @@ original_id: cql_server ## Sub-command `mirror` Complete Parameter - usage: cql mirror [parameter]... dsn/dbid address + usage: cql mirror [common params] [-tmp-path path] [-bg-log-level level] dsn listen_address - Mirror command subscribes database updates and serves a read-only database mirror. + Mirror subscribes database updates and serves a read-only database mirror. e.g. cql mirror database_id 127.0.0.1:9389 @@ -37,9 +38,9 @@ original_id: cql_server See for details of adapter server. - usage: cql adapter [parameter]... address + usage: cql adapter [common params] [-tmp-path path] [-bg-log-level level] [-mirror addr] listen_address - Adapter command serves a SQLChain adapter + Adapter serves a SQLChain adapter. e.g. cql adapter 127.0.0.1:7784 From c144ce9a559c71a4be5644635d7a80767ea34447 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:27 +0800 Subject: [PATCH 313/421] New translations driver_js.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_js.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_js.md b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md index 4cd7824..34edca7 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_js.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_js.md @@ -3,6 +3,7 @@ id: version-0.5.0-driver_js title: JavaScript original_id: driver_js --- + ## Use JavaScript to access CovenantSQL Front-end developers could use [covenantsql-proxy-js](https://github.com/CovenantSQL/covenantsql-proxy-js) to access CovenantSQL through CovenantSQL [Adapter](./adapter). From 7364bd236686863e098ad141b4291eeda309c4a1 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:29 +0800 Subject: [PATCH 314/421] New translations cql_db_manage.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_db_manage.md | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md index b4bc0f8..d85f59e 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql_db_manage title: Database Management original_id: cql_db_manage --- + ## Creating Database Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: @@ -134,24 +135,24 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `create` Complete Parameters - usage: cql create [parameter]... db_meta_json + usage: cql create [common params] [-wait-tx-confirm] db_meta_json - Create CovenantSQL database by database meta info JSON string, meta info must include node count. + Create creates a CovenantSQL database by database meta info JSON string. The meta info must include node count. e.g. - cql create '{"node":2}' - - A complete introduction of db_meta_json fields: - targetminers []string // List of target miner addresses - node int // Target node number - space int // Minimum disk space requirement, 0 for none - memory int // Minimum memory requirement, 0 for none - loadavgpercpu float // Minimum idle CPU requirement, 0 for none - encryptionkey string // Encryption key for persistence data - useeventualconsistency bool // Use eventual consistency to sync among miner nodes - consistencylevel float // Consistency level, node*consistencylevel is the node number to perform strong consistency - isolationlevel int // Isolation level in a single node - - Since CovenantSQL is blockchain database, you may want get confirm of creation. + cql create '{"node": 2}' + + A complete introduction of db_meta_json fields: + target-miners []string // List of target miner addresses + node int // Target node number + space int // Minimum disk space requirement, 0 for none + memory int // Minimum memory requirement, 0 for none + load-avg-per-cpu float // Minimum idle CPU requirement, 0 for none + encrypt-key string // Encryption key for persistence data + eventual-consistency bool // Use eventual consistency to sync among miner nodes + consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency + isolation-level int // Isolation level in a single node + + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. e.g. cql create -wait-tx-confirm '{"node": 2}' @@ -162,15 +163,15 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `drop` Complete Parameters - usage: cql drop [parameter]... dsn/dbid + usage: cql drop [common params] [-wait-tx-confirm] dsn/dbid - Drop command can drop a database by DSN or database id + Drop drops a CovenantSQL database by DSN or database ID. e.g. - cql drop covenantsql://the_dsn_of_your_database + cql drop covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c - Since CovenantSQL is blockchain database, you may want get confirm of drop operation. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect. e.g. - cql drop -wait-tx-confirm covenantsql://the_dsn_of_your_database + cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c Params: -wait-tx-confirm @@ -179,13 +180,13 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio ## Sub-command `grant` Complete Parameters - usage: cql grant [parameter]... permission_meta_json + usage: cql grant [common params] [-wait-tx-confirm] permission_meta_json - Grant command can give a user some specific permissions on your database + Grant grants specific permissions for the target user. e.g. cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' - Since CovenantSQL is blockchain database, you may want get confirm of permission update. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the permission takes effect. e.g. cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' From dc3e17eaef9e0a119c2a79a82fdaa5ac76db6129 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:30 +0800 Subject: [PATCH 315/421] New translations cql_db_access.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_db_access.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md b/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md index 5d4a471..63b0c14 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_db_access.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql_db_access title: Accessing Database original_id: cql_db_access --- + Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: ```bash @@ -21,7 +22,7 @@ Output: co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -Or access as `account2` if it has successfully been granted access permission: +Or access as `account2` if it has been granted access permission successfully: ```bash cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' @@ -60,16 +61,16 @@ Here is an example of using the interactive console: The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. - usage: cql console [parameter]... + usage: cql console [common params] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] - Console command can run a interactive SQL console for CovenantSQL + Console runs an interactive SQL console for CovenantSQL. e.g. - cql console -dsn covenantsql://the_dsn_of_your_database + cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c There is also a -command param for SQL script, and a -file param for reading SQL in a file. If those params are set, it will run SQL script and exit without staying console mode. e.g. - cql console -dsn covenantsql://the_dsn_of_your_database -command "create table test1(test2 int);" + cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c -command "create table test1(test2 int);" Params: -adapter string From 0d029fced709341b55ced7ddd7824bf044f2a4fa Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:32 +0800 Subject: [PATCH 316/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/cql_advance.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md index d7b34ca..d249d29 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_advance.md @@ -3,13 +3,14 @@ id: version-0.5.0-cql_advance title: Advanced Usage original_id: cql_advance --- + Sub-command `rpc` calls the remote process directly in the CovenantSQL network. ## Sub-command `rpc` Complete Parameter - usage: cql rpc [parameter]... + usage: cql rpc [common params] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request - Rpc command make a RPC request to the target server + RPC makes a RPC request to the target endpoint. e.g. cql rpc -name 'MCC.QuerySQLChainProfile' \ -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ From 3d3fbfb43fb4a9aa8c081621fc675fb1eafdb67c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:33 +0800 Subject: [PATCH 317/421] New translations cql_account.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.5.0/cql_account.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_account.md b/website/translated_docs/zh-CN/version-0.5.0/cql_account.md index 2883c9c..911c0df 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_account.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_account.md @@ -3,6 +3,7 @@ id: version-0.5.0-cql_account title: Account Management original_id: cql_account --- + For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. ## Creating New Account @@ -61,9 +62,9 @@ Output: Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. - usage: cql generate [parameter]... config | public + usage: cql generate [common params] config | public - Generate command can generate private.key and config.yaml for CovenantSQL. + Generate generates private.key and config.yaml for CovenantSQL. e.g. cql generate config @@ -103,9 +104,9 @@ Output: ## Sub-command `idminer` Complete Parameters - usage: cql idminer [parameter]... + usage: cql idminer [common params] [-difficulty number] [-loop [true]] - IDMiner command can calculate legal node id and it's nonce. Default 24 difficulty and no endless loop. + IDMiner calculates legal node id and it's nonce. Default parameters are difficulty of 24 and no endless loop. e.g. cql idminer -difficulty 24 From ad5eddafa0d5f18ad1359f44c617436325ead9ec Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:35 +0800 Subject: [PATCH 318/421] New translations usecase_traditional_app.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/usecase_traditional_app.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md index f6fff06..6ea9f47 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_traditional_app.md @@ -3,6 +3,7 @@ id: version-0.5.0-usecase_traditional_app title: Traditional App original_id: usecase_traditional_app --- + ## Privacy data If you are a developper of password management tools just like [1Password](https://1password.com/) or [LastPass](https://www.lastpass.com/). You can use CQL as the database to take benefits: From c31a3b17078ddb3d1c5df82f870b7c4a4b3da8fb Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:39 +0800 Subject: [PATCH 319/421] New translations usecase_data_analysis.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md index 3d70ac6..3394b2d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md @@ -3,6 +3,7 @@ id: version-0.5.0-usecase_data_analysis title: Data Analysis original_id: usecase_data_analysis --- + ## 关于 Quandl Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 From 3ccf29ee7c6cef7c001854d8c1b78a8f04ea1f96 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:40 +0800 Subject: [PATCH 320/421] New translations usecase_dapp.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md index 6436350..31b7e1b 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_dapp.md @@ -3,4 +3,5 @@ id: version-0.5.0-usecase_dapp title: DApp original_id: usecase_dapp --- + Storing data on Bitcoin or Ethereum is quite expensive ($4305 / MB on Ethereum 2018-05-15). Programming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world. \ No newline at end of file From c8db82c57541f5f3ca7c5264eb1a3d743a2ef71e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:42 +0800 Subject: [PATCH 321/421] New translations driver_golang.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_golang.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md index 482d5d3..975c8a9 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_golang.md @@ -3,6 +3,7 @@ id: version-0.5.0-driver_golang title: Golang original_id: driver_golang --- + ## Use Golang to access CovenantSQL `CovenantSQL` provides `Golang SDK` to access database using native rpc protocol. The `cql` tool is developed based on `Golang SDK`. From ffb3445f9ce97bacec79406b904dcfd7ceef9ba6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:43 +0800 Subject: [PATCH 322/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_python.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md index 7b947e5..417c6f9 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -3,6 +3,7 @@ id: version-0.5.0-driver_python title: Python original_id: driver_python --- + ## Use Python to access CovenantSQL Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). From a0ff970ea5db6e1f5c3bf2d64488a5d4e972ea58 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:44 +0800 Subject: [PATCH 323/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_java.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index 926f79a..bd73fcb 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -3,6 +3,7 @@ id: version-0.5.0-driver_java title: Java original_id: driver_java --- + ## Use Java to access CovenantSQL `CovenantSQL` provides `Java SDK` to access database instance through [`Adapter`](./adapter) service. From 329dded25b56ec1e4b8d90360168a0817193ac5e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:46 +0800 Subject: [PATCH 324/421] New translations deployment-en.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/deployment-en.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md index 9e1ca7a..ff73566 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md +++ b/website/translated_docs/zh-CN/version-0.5.0/deployment-en.md @@ -3,6 +3,7 @@ id: version-0.5.0-deployment title: Docker one-line deployment original_id: deployment --- + ## Deploy with CovenantSQL Docker ### Install Docker From 4b0ca8ecc4aa774fdf4f7c03d86d18b44225fa71 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:43:47 +0800 Subject: [PATCH 325/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/adpater.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/adpater.md b/website/translated_docs/zh-CN/version-0.5.0/adpater.md index bbf194f..8243854 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/adpater.md +++ b/website/translated_docs/zh-CN/version-0.5.0/adpater.md @@ -3,6 +3,7 @@ id: version-0.5.0-adapter title: Adapter original_id: adapter --- + # Use Adapter to access CovenantSQL `CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. From ed3c281ef6d20b076fce3306e54fee20f3e8c702 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:52 +0800 Subject: [PATCH 326/421] New translations advanced_deployment.md (Chinese Simplified) --- .../zh-CN/advanced_deployment.md | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 website/translated_docs/zh-CN/advanced_deployment.md diff --git a/website/translated_docs/zh-CN/advanced_deployment.md b/website/translated_docs/zh-CN/advanced_deployment.md new file mode 100644 index 0000000..b5137d9 --- /dev/null +++ b/website/translated_docs/zh-CN/advanced_deployment.md @@ -0,0 +1,159 @@ +--- +id: advanced_deployment +title: Private Deploy +--- + +## Deploy with CovenantSQL Docker + +### Install Docker + +You need to install docker and docker-compose on your machine to deploy CovenantSQL. + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### Download project + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +### Start Docker container + +There are now two ways to start the CovenantSQL container: + +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image + +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. + +#### 1. Use a public image on Docker Hub + +Then start directly: + +```bash +make start +``` + +#### 2. Build a CovenantSQL Docker image + +Run CovenantSQL locally by executing the following command + +```bash +make docker # compile a new image from source files +make start +``` + +### Check running status + +Check the container status: + +```bash +docker-compose ps +``` + +Confirm that all components are in the `Up` state + + Name Command State Ports + ------------------------------------------------------------------------------------------------------ + covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp + covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp + covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp + covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp + covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp + covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp + covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp + covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp + covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp + covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + + +## Operate CovenantSQL + +### Create a database + +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. + +e.g.: creating a single-node database instance + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +The command will return the connection string of the created database instance + + covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + + +### Accessing the database + +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: + +```bash +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +After that, it will get the following output, and enter the `cql` interactive command line mode + +``` + +Connected with driver covenantsql (develop) Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + +
The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + + ```sql + CREATE TABLE test (test TEXT); + SHOW TABLES; + INSERT INTO test VALUES("happy"); + SELECT * FROM test; + + +After that, it will get the following output: + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); + CREATE TABLE + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name + ------ + test + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); + INSERT + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test + ------- + happy + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + + +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line + +### SQLChain Observer + +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. + +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) + +#### Use SQLChain Observer in your browser + +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From e3be21f346db30cb791b576a9ac311ccda673b7a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:53 +0800 Subject: [PATCH 327/421] New translations advanced_secure_gateway.md (Chinese Simplified) --- .../zh-CN/advanced_secure_gateway.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 website/translated_docs/zh-CN/advanced_secure_gateway.md diff --git a/website/translated_docs/zh-CN/advanced_secure_gateway.md b/website/translated_docs/zh-CN/advanced_secure_gateway.md new file mode 100644 index 0000000..04a120f --- /dev/null +++ b/website/translated_docs/zh-CN/advanced_secure_gateway.md @@ -0,0 +1,79 @@ +--- +id: advanced_secure_gateway +title: Secure Gateway +--- + +## SecureGateway + +CQL SecureGateway (CGS) is currently only available to enterprise users. If you have in-depth understanding or trial requirements, please [contact us](mailto:info@covenantsql.io). + +### Architecture + +![CovenantSQL.SecureGateway](https://github.com/CovenantSQL/docs/raw/master/website/static/img/CovenantSQL.SecureGateway.png) + +### API + +CGS uses the binary protocol of MySQL 5.x, and all language drivers compatible with MySQL 5.x can be used directly. + +### ACL Config + +Support for **User/User Group** and **Column/Column Group** combination authorization (columns are represented as **database.table.column** triples) + +#### ACL Example + +The settings are divided into two parts, `Group` and `Strategy`, as follows: + +User Group + +| User | Group | +| ----- | --------------- | +| user1 | admin,userGroup | +| user2 | admin,userGroup | +| user3 | userGroup | + +Column Group + +| Column | Group | +| ------------- | -------- | +| db1.tbl1.col2 | someCols | +| db1.tbl1.col3 | someCols | +| db1.tbl1.col4 | someCols | + +Strategy + +| User/Group | Column/Group | Permission(Write/Read) | +| ---------- | ------------- | ---------------------- | +| user1 | db1.tbl1.col1 | write | +| user2 | db1.tbl1.col1 | read | +| admin | someCols | read | +| userGroup | db1.tbl2.col1 | read | +| userGroup | db2.tbl1.* | read | + +### Encryption Config + +Support for configuring encryption settings in the form of fields & encryption keys (fields are represented as **database.table.field** triples) Encryption/decryption is valid only if the user has permission to the field. + +#### Example + +Keys + +| Column | Key | +| ------------- | ---- | +| db1.tbl1.col1 | key1 | +| db1.tbl1.col2 | key2 | +| db1.tbl1.col3 | key3 | +| db1.tbl2.col1 | key1 | +| db2.tbl1.col1 | key1 | + +In conjunction with the configuration of `ACL` & `Keys` above, the access restrictions that are in effect are as follows: + +Result + +| database | table | column | key | user permissions | +| -------- | ----- | ------ | ---- | ----------------------- | +| db1 | tbl1 | col1 | key1 | user1 write; user2 read | +| db1 | tbl1 | col2 | key2 | user1 read; user2 read | +| db1 | tbl1 | col3 | key3 | user1 read; user2 read | +| db1 | tbl1 | col4 | | user1 read; user2 read | +| db1 | tbl2 | col1 | key1 | userGroup read | +| db2 | tbl1 | * | key1 | userGroup read | \ No newline at end of file From f6dfbcd84fdca2211f3facc6feba668cf3858728 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:54 +0800 Subject: [PATCH 328/421] New translations arch_layers.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch_layers.md | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 website/translated_docs/zh-CN/arch_layers.md diff --git a/website/translated_docs/zh-CN/arch_layers.md b/website/translated_docs/zh-CN/arch_layers.md new file mode 100644 index 0000000..89e4cc2 --- /dev/null +++ b/website/translated_docs/zh-CN/arch_layers.md @@ -0,0 +1,29 @@ +--- +id: arch_layers +title: Blockchains +--- + + +## MainChain & SQLChain + +CQL uses a layered architecture for database creation and operation. A typical data creation process can be roughly as follows: + +1. Miner will automatically register with the MainChain after startup. The registration information includes: "Minimum acceptable Gas price", "System metrics", "External IP and port", etc. +2. Miner subscribes to and pays attention to information related to themselves through ChainBus; +3. The client runs `cql create '{"node":2}'` to send a signed database creation request to any BP (Block Producer) in the MainChain; +4. The BP that received the request performs a match of Miner and database creation request in the process of producing the block (see: \[MainChain Produce Block\] (#mainchain-produce-block)); +5. Database creation requests and matching results are verified and confirmed at other BP nodes; +6. The Miner subscription receives the database task; +7. Miners discover and connect with each other through Kayak to form a SQLChain database cluster; +8. All miners are ready to wait for a request; +9. Users can connect to the database and execute SQL through the `cql console` command. + +See the image below to view [Large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): + +![2layers](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg) + +## MainChain Produce Block + +The complete main chain export process is complicated. Please refer to the numbers in the figure below for understanding. For the big picture, please click [here](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) + +![MainChain Produce Block](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) \ No newline at end of file From ee898e4f6817b2ebfa1eb8c70eec72d52099a0d4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:55 +0800 Subject: [PATCH 329/421] New translations advanced_deployment.md (Chinese Simplified) --- .../version-0.5.0/advanced_deployment.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/advanced_deployment.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/advanced_deployment.md b/website/translated_docs/zh-CN/version-0.5.0/advanced_deployment.md new file mode 100644 index 0000000..418a45c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/advanced_deployment.md @@ -0,0 +1,160 @@ +--- +id: version-0.5.0-advanced_deployment +title: Private Deploy +original_id: advanced_deployment +--- + +## Deploy with CovenantSQL Docker + +### Install Docker + +You need to install docker and docker-compose on your machine to deploy CovenantSQL. + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### Download project + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +### Start Docker container + +There are now two ways to start the CovenantSQL container: + +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image + +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. + +#### 1. Use a public image on Docker Hub + +Then start directly: + +```bash +make start +``` + +#### 2. Build a CovenantSQL Docker image + +Run CovenantSQL locally by executing the following command + +```bash +make docker # compile a new image from source files +make start +``` + +### Check running status + +Check the container status: + +```bash +docker-compose ps +``` + +Confirm that all components are in the `Up` state + + Name Command State Ports + ------------------------------------------------------------------------------------------------------ + covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp + covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp + covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp + covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp + covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp + covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp + covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp + covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp + covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp + covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + + +## Operate CovenantSQL + +### Create a database + +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. + +e.g.: creating a single-node database instance + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +``` + +The command will return the connection string of the created database instance + + covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + + +### Accessing the database + +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: + +```bash +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +After that, it will get the following output, and enter the `cql` interactive command line mode + +``` + +Connected with driver covenantsql (develop) Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + +
The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + + ```sql + CREATE TABLE test (test TEXT); + SHOW TABLES; + INSERT INTO test VALUES("happy"); + SELECT * FROM test; + + +After that, it will get the following output: + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); + CREATE TABLE + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name + ------ + test + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); + INSERT + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test + ------- + happy + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + + +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line + +### SQLChain Observer + +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. + +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) + +#### Use SQLChain Observer in your browser + +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From 164c918d3f05fdb3096ee729ffbd13ce95fb0f84 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:57 +0800 Subject: [PATCH 330/421] New translations advanced_secure_gateway.md (Chinese Simplified) --- .../version-0.5.0/advanced_secure_gateway.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/advanced_secure_gateway.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/advanced_secure_gateway.md b/website/translated_docs/zh-CN/version-0.5.0/advanced_secure_gateway.md new file mode 100644 index 0000000..1850818 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/advanced_secure_gateway.md @@ -0,0 +1,80 @@ +--- +id: version-0.5.0-advanced_secure_gateway +title: Secure Gateway +original_id: advanced_secure_gateway +--- + +## SecureGateway + +CQL SecureGateway (CGS) is currently only available to enterprise users. If you have in-depth understanding or trial requirements, please [contact us](mailto:info@covenantsql.io). + +### Architecture + +![CovenantSQL.SecureGateway](https://github.com/CovenantSQL/docs/raw/master/website/static/img/CovenantSQL.SecureGateway.png) + +### API + +CGS uses the binary protocol of MySQL 5.x, and all language drivers compatible with MySQL 5.x can be used directly. + +### ACL Config + +Support for **User/User Group** and **Column/Column Group** combination authorization (columns are represented as **database.table.column** triples) + +#### ACL Example + +The settings are divided into two parts, `Group` and `Strategy`, as follows: + +User Group + +| User | Group | +| ----- | --------------- | +| user1 | admin,userGroup | +| user2 | admin,userGroup | +| user3 | userGroup | + +Column Group + +| Column | Group | +| ------------- | -------- | +| db1.tbl1.col2 | someCols | +| db1.tbl1.col3 | someCols | +| db1.tbl1.col4 | someCols | + +Strategy + +| User/Group | Column/Group | Permission(Write/Read) | +| ---------- | ------------- | ---------------------- | +| user1 | db1.tbl1.col1 | write | +| user2 | db1.tbl1.col1 | read | +| admin | someCols | read | +| userGroup | db1.tbl2.col1 | read | +| userGroup | db2.tbl1.* | read | + +### Encryption Config + +Support for configuring encryption settings in the form of fields & encryption keys (fields are represented as **database.table.field** triples) Encryption/decryption is valid only if the user has permission to the field. + +#### Example + +Keys + +| Column | Key | +| ------------- | ---- | +| db1.tbl1.col1 | key1 | +| db1.tbl1.col2 | key2 | +| db1.tbl1.col3 | key3 | +| db1.tbl2.col1 | key1 | +| db2.tbl1.col1 | key1 | + +In conjunction with the configuration of `ACL` & `Keys` above, the access restrictions that are in effect are as follows: + +Result + +| database | table | column | key | user permissions | +| -------- | ----- | ------ | ---- | ----------------------- | +| db1 | tbl1 | col1 | key1 | user1 write; user2 read | +| db1 | tbl1 | col2 | key2 | user1 read; user2 read | +| db1 | tbl1 | col3 | key3 | user1 read; user2 read | +| db1 | tbl1 | col4 | | user1 read; user2 read | +| db1 | tbl2 | col1 | key1 | userGroup read | +| db2 | tbl1 | * | key1 | userGroup read | \ No newline at end of file From 12e9ae935c1cfd04ddd7bf2cb758cf5cb9a82160 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 23 Apr 2019 23:49:58 +0800 Subject: [PATCH 331/421] New translations arch_layers.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/arch_layers.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.5.0/arch_layers.md diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md b/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md new file mode 100644 index 0000000..1236615 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md @@ -0,0 +1,30 @@ +--- +id: version-0.5.0-arch_layers +title: Blockchains +original_id: arch_layers +--- + + +## MainChain & SQLChain + +CQL uses a layered architecture for database creation and operation. A typical data creation process can be roughly as follows: + +1. Miner will automatically register with the MainChain after startup. The registration information includes: "Minimum acceptable Gas price", "System metrics", "External IP and port", etc. +2. Miner subscribes to and pays attention to information related to themselves through ChainBus; +3. The client runs `cql create '{"node":2}'` to send a signed database creation request to any BP (Block Producer) in the MainChain; +4. The BP that received the request performs a match of Miner and database creation request in the process of producing the block (see: \[MainChain Produce Block\] (#mainchain-produce-block)); +5. Database creation requests and matching results are verified and confirmed at other BP nodes; +6. The Miner subscription receives the database task; +7. Miners discover and connect with each other through Kayak to form a SQLChain database cluster; +8. All miners are ready to wait for a request; +9. Users can connect to the database and execute SQL through the `cql console` command. + +See the image below to view [Large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): + +![2layers](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg) + +## MainChain Produce Block + +The complete main chain export process is complicated. Please refer to the numbers in the figure below for understanding. For the big picture, please click [here](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) + +![MainChain Produce Block](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) \ No newline at end of file From ba2c7396446f3a26b024ae1cced5ad360ed1ecd7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 25 Apr 2019 18:08:43 +0800 Subject: [PATCH 332/421] New translations arch_layers.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch_layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/arch_layers.md b/website/translated_docs/zh-CN/arch_layers.md index 89e4cc2..6be185d 100644 --- a/website/translated_docs/zh-CN/arch_layers.md +++ b/website/translated_docs/zh-CN/arch_layers.md @@ -18,7 +18,7 @@ CQL uses a layered architecture for database creation and operation. A typical d 8. All miners are ready to wait for a request; 9. Users can connect to the database and execute SQL through the `cql console` command. -See the image below to view [Large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): +See the image below to view [large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): ![2layers](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg) From db4c42271d236fa73ac3c84e34daf18d44b97663 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 25 Apr 2019 18:08:49 +0800 Subject: [PATCH 333/421] New translations qna.md (Chinese Simplified) --- website/translated_docs/zh-CN/qna.md | 52 +++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/qna.md b/website/translated_docs/zh-CN/qna.md index 2e053d8..0e2b596 100644 --- a/website/translated_docs/zh-CN/qna.md +++ b/website/translated_docs/zh-CN/qna.md @@ -5,4 +5,54 @@ title: Q&A ## Frequently Asked -- \ No newline at end of file +- **Q:** What level of consistency does the CQL database support and how is the CQL database created? + + **A:** See [Consensus Algorithm](./arch#consensus-algorithm) + +- **Q:** How is CQL database security done? + + **A:** Unlike traditional databases, CQL is a distributed database system that runs on the open Internet. In terms of security, CQL mainly does the following work: + + 1. Key Management: CQL uses public and private key pairs generated by Bitcoin's `scep256k1` asymmetric encryption curve. + + 2. Network communication: see [RPC Framework](./arch_network)。 + + 3. Database Permissions & Encryption: + + 1. [Secure Gateway](./advanced_secure_gateway) + + 2. Support of SQL encryption functions `encrypt`, `decrypt`, for example: + + ```sql + INSERT INTO "t1" ("k", "v") VALUES (1, encrypt("data", "pass", "salt")); + SELECT decrypt("v", "pass", "salt") FROM "t1" WHERE "k"=1; + ``` + +- **Q:** If CQL data is Immutable, how do CQL deal with the need for data deletion in GDPR? + + **A:** CQL supports two development modes, one is the traditional `DB per App`, and the other is the `DB per User` which is biased towards privacy. + + The development mode of `DB per User` is very suitable for the development of applications such as "Password Manager" and "Personal Information Management". Since users manage their personal data through a CQL private key which is quite like using Bitcoin a private key to manage their own property. App developed in this model naturally does not store any user data, and technically conforms to the following Stringent requirements of laws and regulations: + + - [EU GDPR(General Data Protection Regulation)](https://gdpr-info.eu/) + - [CCPA(California_Consumer_Privacy_Act)](https://en.wikipedia.org/wiki/California_Consumer_Privacy_Act) + - [HIPAA(Health Insurance Portability and Accountability Act of 1996)](https://en.wikipedia.org/wiki/Health_Insurance_Portability_and_Accountability_Act) + - [HongKong Personal Data (Privacy) Ordinance](https://www.elegislation.gov.hk/hk/cap486) + + The complete data of CQL is stored on Miner of SQLChain. The data related SQL history is completely saved on Miner. Compared to the traditional database `CRUD` (Create, Read, Update, Delete), CQL supports `CRAP` (Create, Read, Append, Privatize). + + > **Append** vs **Update** + > + > After the traditional database changes the data (Update), there is no history, in other words, the data can be tampered with. CQL supports the Append of data, and the result is that the history of the data is preserved. + > + > **Privatize** vs **Delete** + > + > The traditional database deletes the data (Delete), which is irreversible and irreversible. CQL supports Privatization of data, that is, transferring the permissions of the database to an impossible public key. This allows substantial deletion of sub-chain data. Deletion of all traces on the chain for a single piece of data is currently only supported in the Enterprise Edition. + +- **Q:** How does CQL store data for a database? + + **A:** Most of the operation of the user database is done on SQLChain. By default, the MainChain only saves the block hash of the SQLChain. For more details, please refer to [MainChain & SQLChain](./arch_layers#mainchain-sqlchain)。 + +- **Q:** What is the maximum amount of data supported by CQL? + + **A:** CQL's database data is stored on a separate SQLChain. The number of CQL databases depends on the number of Miners across the network. The upper limit of a single CQL database depends on the hardware performance. As of 2019-04-25, the largest table online of TestNet is a 2 Miner database running continuously on a AWS c5.2xlarge standard configuration with 433,211,000 rows of data and 3.2 TB of disk. \ No newline at end of file From e579698bcffc33e14fa9473df78b522c7a7b474c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 25 Apr 2019 18:09:04 +0800 Subject: [PATCH 334/421] New translations qna.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/qna.md | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/qna.md b/website/translated_docs/zh-CN/version-0.5.0/qna.md index 9ea15e1..c76054c 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/qna.md +++ b/website/translated_docs/zh-CN/version-0.5.0/qna.md @@ -6,4 +6,54 @@ original_id: qna ## Frequently Asked -- \ No newline at end of file +- **Q:** What level of consistency does the CQL database support and how is the CQL database created? + + **A:** See [Consensus Algorithm](./arch#consensus-algorithm) + +- **Q:** How is CQL database security done? + + **A:** Unlike traditional databases, CQL is a distributed database system that runs on the open Internet. In terms of security, CQL mainly does the following work: + + 1. Key Management: CQL uses public and private key pairs generated by Bitcoin's `scep256k1` asymmetric encryption curve. + + 2. Network communication: see [RPC Framework](./arch_network)。 + + 3. Database Permissions & Encryption: + + 1. [Secure Gateway](./advanced_secure_gateway) + + 2. Support of SQL encryption functions `encrypt`, `decrypt`, for example: + + ```sql + INSERT INTO "t1" ("k", "v") VALUES (1, encrypt("data", "pass", "salt")); + SELECT decrypt("v", "pass", "salt") FROM "t1" WHERE "k"=1; + ``` + +- **Q:** If CQL data is Immutable, how do CQL deal with the need for data deletion in GDPR? + + **A:** CQL supports two development modes, one is the traditional `DB per App`, and the other is the `DB per User` which is biased towards privacy. + + The development mode of `DB per User` is very suitable for the development of applications such as "Password Manager" and "Personal Information Management". Since users manage their personal data through a CQL private key which is quite like using Bitcoin a private key to manage their own property. App developed in this model naturally does not store any user data, and technically conforms to the following Stringent requirements of laws and regulations: + + - [EU GDPR(General Data Protection Regulation)](https://gdpr-info.eu/) + - [CCPA(California_Consumer_Privacy_Act)](https://en.wikipedia.org/wiki/California_Consumer_Privacy_Act) + - [HIPAA(Health Insurance Portability and Accountability Act of 1996)](https://en.wikipedia.org/wiki/Health_Insurance_Portability_and_Accountability_Act) + - [HongKong Personal Data (Privacy) Ordinance](https://www.elegislation.gov.hk/hk/cap486) + + The complete data of CQL is stored on Miner of SQLChain. The data related SQL history is completely saved on Miner. Compared to the traditional database `CRUD` (Create, Read, Update, Delete), CQL supports `CRAP` (Create, Read, Append, Privatize). + + > **Append** vs **Update** + > + > After the traditional database changes the data (Update), there is no history, in other words, the data can be tampered with. CQL supports the Append of data, and the result is that the history of the data is preserved. + > + > **Privatize** vs **Delete** + > + > The traditional database deletes the data (Delete), which is irreversible and irreversible. CQL supports Privatization of data, that is, transferring the permissions of the database to an impossible public key. This allows substantial deletion of sub-chain data. Deletion of all traces on the chain for a single piece of data is currently only supported in the Enterprise Edition. + +- **Q:** How does CQL store data for a database? + + **A:** Most of the operation of the user database is done on SQLChain. By default, the MainChain only saves the block hash of the SQLChain. For more details, please refer to [MainChain & SQLChain](./arch_layers#mainchain-sqlchain)。 + +- **Q:** What is the maximum amount of data supported by CQL? + + **A:** CQL's database data is stored on a separate SQLChain. The number of CQL databases depends on the number of Miners across the network. The upper limit of a single CQL database depends on the hardware performance. As of 2019-04-25, the largest table online of TestNet is a 2 Miner database running continuously on a AWS c5.2xlarge standard configuration with 433,211,000 rows of data and 3.2 TB of disk. \ No newline at end of file From 69f4906106e1a9bb3563ad0e0a47d0f3d4e68a2f Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 25 Apr 2019 18:09:07 +0800 Subject: [PATCH 335/421] New translations arch_layers.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/arch_layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md b/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md index 1236615..da5b111 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md +++ b/website/translated_docs/zh-CN/version-0.5.0/arch_layers.md @@ -19,7 +19,7 @@ CQL uses a layered architecture for database creation and operation. A typical d 8. All miners are ready to wait for a request; 9. Users can connect to the database and execute SQL through the `cql console` command. -See the image below to view [Large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): +See the image below to view [large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): ![2layers](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg) From 3ae5019f8ec4c0fbb908ce72eaa378514fc84183 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Sun, 28 Apr 2019 16:05:00 +0800 Subject: [PATCH 336/421] New translations usecase_data_analysis.md (Chinese Simplified) --- .../version-0.5.0/usecase_data_analysis.md | 482 +++++++++--------- 1 file changed, 242 insertions(+), 240 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md index 3394b2d..cb67b28 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md +++ b/website/translated_docs/zh-CN/version-0.5.0/usecase_data_analysis.md @@ -4,296 +4,298 @@ title: Data Analysis original_id: usecase_data_analysis --- -## 关于 Quandl +# Financial data analysis based on Quandl -Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 +## About Quandl -## Quandl 数据索引 +Quandl is a big data platform for the financial investment industry. Its data sources include public data such as the United Nations, the World Bank, and the Central Bank. The core financial data comes from CLS Group, Zacks and ICE. All data comes from more than 500 publishers. It is the preferred platform for investment professionals to provide financial, economic and alternative data with vast economic and financial data. -### CovenantSQL 使用简介 +## Quandl Data Index -首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 +### Introduction to CovenantSQL -现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 +First, we have stored the data in CovenantSQL based on Quandl's open API. Next, you should take a look at the introduction of CovenantSQL to know how to connect and use CovenantSQL. -具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) +Now due to client compatibility issues, please use our HTTP service to query the Quandl database directly. This document will be updated as soon as possible after the current cql client is compatible. -所需参数: +Use CovenantSQL specifically through the HTTP service. Please refer to the Python driver documentation and the NodeJS driver documentation. + +Required parameters: host: 'e.morenodes.com' - port: 11108 + port: 11111 database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' -### 数据使用方法 +### How to use CQL-Quandl -Quandl 数据分为表以及子表两层索引 +Quandl data is divided into tables and sub-tables -数据库中,表名为`quandl_` + `database_code`为完整表名 +In the database, the table name is `quandl_ + database_code` for the full table name -通过查询表名来查看表的内容 +View the contents of the table by querying the table name -具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) +For specific use, you need to use the `quandl_updateindex` index table to use it. (When querying the index table, be sure to limit less than 100,000 because the full data is too large) -使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 +Please using the `where` statement to qualify the `quandlcode` field to query the sub table data in the table. -### 查询示例 +## Example -1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: - - `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` +1. We want to query the data of the European Commission's annual macroeconomic database. We find the database code of its first index is `quandl_ameco`, so we can query its second index, using the following SQL command line: -2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 - - 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 - - Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania - - 于是,我们可以用以下方式把这个子表给查询出来 - - `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` +```SQL + select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000; + ``` + +2. Then through the third column, we can see the description corresponding to the `quandlcode` -3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + For example, `AMECO/ALB_1_0_0_0_AAGE` corresponds to the import and export information of Albania from 1960 to 1988. -## Quandl 数据 Excel 插件使用说明 + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania -您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + So, we can query this subtable in the following way. -### 配置 Excel 插件 + ```SQL + select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000; + ``` -解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 +3. Note: If the content of the content is null, it belongs to the field that does not exist in the table structure itself, you can remove it yourself. -#### 修改 xml 配置 +# Quandl Data Excel Plugin Instructions -每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: +You can download the Quandl Data Excel plugin without having to install it, unzip it into any folder. This plugin currently only supports Office 2010 and above, and Office 2007 and below are currently not supported. + +## Configuring the Excel plugin + +Unzip the downloaded package. There are two .xll files in the folder, `ClassLibrary7-AddIn.xll` and `ClassLibrary7-AddIn64.xll` files. These two files correspond to 32-bit Excel and 64-bit Excel respectively. Please refer to your The computer configuration uses the corresponding plugin. + +### Modify the xml configuration + +Each .xll file corresponds to a .config configuration file, which is `ClassLibrary7-AddIn.xll.config` and `ClassLibrary7-AddIn64.xll.config`, configured for the following xml: ```xml - - - + + + ``` -其中有如下配置需要修改,并保存: +The following configuration needs to be modified and saved: -- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 +`Certpath`: Please fill in the absolute path of the `read.data.covenantsql.io.pfx` certificate -#### 安装插件 +### Plugin installation -有两种办法使用此 Excel 插件 +There are two ways to use this Excel plugin -1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 +1. Double-click the corresponding 32-bit or 64-bit Excel xll file to open it. ![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) -如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 +If the above dialog box shows up, select the first one: Enable this add-on only for this callback. Then create a new Excel table. If you see CovenantSQL in the upper tab of Excel, the plugin is loaded successfully. -2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: +2. Open Excel, then select File - Options - Add-ons, Manage Select Excel Add-Ins, click Go and browse to select the .xll file for the corresponding version after decompression, and then click OK. If you successfully load CovenantSQL in the tab, Successfully loaded, as shown below: ![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) -#### 使用插件 - -选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: - -![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) +### How to use plugin -- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 +Select the CovenantSQL tab to see the Quandl data query. Click on the Quandl data query and a pop-up will appear as shown below: -- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3_en.png) -- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 +- The part of the list that is framed by red is the first-level directory, and the lower part is the specific description of the selected item. +- The green button queries the se condary directory by selecting the primary directory. The query time will vary depending on the size of the secondary directory being queried and the user's own network speed. The query time may exceed 1 minute. Please be patient. +- The list on the left of the yellow part is the secondary directory, and the form on the right is the description of the table selected by the list item. -- 蓝色部分是导出数据的可选项 +- The blue part is an option to export data - - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 - - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) - -现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 - -## 附件表 - -| DataBase | 名称 | 描述 | -| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | -| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | -| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | -| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | -| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | -| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | -| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | -| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | -| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | -| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | -| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | -| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | -| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | -| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | -| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | -| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | -| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | -| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | -| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | -| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | -| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | -| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | -| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | -| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | -| GDT | 全球乳品贸易数据 | nan | -| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | -| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | -| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | -| LOCALBTC | Local Bitcoins数据 | nan | -| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | -| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | -| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | -| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | -| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | -| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | -| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | -| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | -| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | -| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | -| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | -| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | -| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | -| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | -| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | -| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | -| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | -| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | -| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | -| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | -| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | -| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | -| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | -| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | -| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | -| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | -| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | -| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | -| CEGH | 中欧天然气中心数据 | nan | -| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | -| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | -| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | -| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | -| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | -| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | -| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | -| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | -| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | -| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | -| GPP | 全球石油价格 | nan | -| PPE | 波兰电力交易所(TGE)数据 | nan | -| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | -| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | -| WSE | 华沙证券交易所(GPW)数据 | nan | -| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | -| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | -| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | -| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | -| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | -| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | -| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | -| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | -| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | -| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | -| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | -| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | -| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | -| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | -| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | -| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | -| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | -| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | -| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | -| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | -| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | -| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | -| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | -| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | -| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | -| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | -| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | -| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | -| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | -| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | -| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | -| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | -| MAS | 新加坡金融管理局数据 | nan | -| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | -| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | -| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | -| UKR | 乌克兰交易所数据 | nan | -| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | -| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | -| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | -| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | -| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | -| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | -| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | -| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | -| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | -| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | -| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | -| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | -| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | -| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | -| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | -| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | -| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | -| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | -| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | -| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | -| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | -| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | -| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | -| NAHB | 美国住房指数 | 美国的住房和经济指数。 | -| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | -| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | -| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | -| MULTPL | S&P 500 | nan | -| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | -| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | -| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | -| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | -| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | -| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | -| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | -| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | -| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | -| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | -| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | -| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | -| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | -| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | -| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | -| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | -| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | -| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | -| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | -| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | -| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | -| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | -| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | -| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | -| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | -| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | -| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | -| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | -| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | -| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | -| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | -| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | -| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | -| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | -| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | -| BOJ | 日本银行数据 | nan | -| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | -| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | -| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | -| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file + - Limit Number is the maximum number of data exported at a time. The default is 10000, and the maximum value can be filled in 100000. + - Offset Number is derived from the first few columns of the database, because the number of bars is limited. For example, we exported 10000 data before, but the obvious data has not been exported yet. We can use this function to select offset 10000 to start from the 10000th. Export (Note: the database count starts from 0, so the first 10000 is 0-9999) + +## Attachment + +| Database | Name | description | +| ------------ | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| PIKETTY | Thomas Piketty | Data on Income and Wealth from "Capital in the 21st Century", Harvard University Press 2014. | +| BUNDESBANK | Deutsche Bundesbank Data Repository | Data on the German economy, money and capital markets, public finances, banking, households, Euro-area aggregates, trade and external debt. | +| URC | Unicorn Research Corporation | Advance and decline data for the NYSE, AMEX, and NASDAQ stock exchanges. From various publicly-available sources and the median value is reported. | +| DCE | Dalian Commodities Exchange | Agriculture and commodities futures from DCE, with history spanning almost a decade for select futures. | +| WFC | Wells Fargo Home Mortgage Loans | This database offers mortgage purchase and refinance rates from Wells Fargo Home Mortgage, a division of Wells Fargo Bank. | +| USDAFNS | U.S. Department of Agriculture FNS | Food and Nutrition Service administrates federal nutrition assistance programs for low-income households and children. Data on costs and participation rates. | +| LJUBSE | Ljubljana Stock Exchange (Slovenia) | This database contains the Ljubljana Stock Exchange indexes and is based in Ljubljana, Slovenia. | +| TOCOM | Tokyo Commodities Exchange | Agriculture and commodities futures from Tokyo Commodities Exchange (TOCOM), with history spanning almost a decade for select futures. | +| WCSC | World Bank Corporate Scorecard | This database is designed to provide a strategic overview of the World Bank Group’s performance toward ending extreme poverty and promoting shared prosperity. | +| CMHC | Canadian Mortgage and Housing Corporation | The CMHC is a gov’t-owned corporation that provides affordable housing to Canadian citizens and collects data such as prices, construction, and supply. | +| WGEC | World Bank Global Economic Monitor (GEM) Commodities | Data containing commodity prices and indices from 1960 to present. | +| FED | US Federal Reserve Data Releases | Official US figures on money supply, interest rates, mortgages, government finances, bank assets and debt, exchange rates, industrial production. | +| WPSD | World Bank Public Sector Debt | Data jointly developed by the World Bank and the International Monetary Fund, which brings together detailed public sector government debt data. | +| UGID | United Nations Global Indicators | This database offers a wide range of global indicators, covering population, public health, employment, trade, education, inflation and external debt. | +| RBA | Reserve Bank of Australia | Central bank and monetary authority, regulates banking industry, sets interest rates, and services governments debt. Data on key economic indicators. | +| UCOM | United Nations Commodity Trade | This database offers comprehensive global data on imports and exports of commodities such as food, live animals, pharmaceuticals, metals, fuels and machinery. | +| SIDC | Solar Influences Data Analysis Center | The SIDC hosts data spanning from the 1700s on solar activity, specifically sunspot activity. | +| ZCE | Zhengzhou Commodities Exchange | Agriculture and commodities futures from ZCE, with history spanning almost a decade for select futures. | +| USDAFAS | U.S. Department of Agriculture FAS | The USDA Foreign Agricultural Service connects U.S. agriculture with the world markets. It provides statistics on production and exports in foreign countries. | +| OECD | Organisation for Economic Co-operation and Development | International organization of developed countries that promotes economic welfare. Collects data from members and others to make policy recommendations. | +| OPEC | Organization of the Petroleum Exporting Countries | International organization and economic cartel overseeing policies of oil-producers, such as Iraq, Iran, Saudi Arabia, and Venezuela. Data on oil prices. | +| MCX | Multi Commodity Exchange India | Indias largest commodity exchange servicing futures trading in metals, energy, and agriculture. Worlds 3rd largest exchange in contracts and trading volume. | +| ECONOMIST | The Economist - Big Mac Index | The Big Mac index was invented by The Economist in 1986 as a lighthearted guide to whether currencies are at their “correct” level. It is based on the theory of purchasing-power parity (PPP). | +| NSDL | National Securities Depository Limited (India) | Depository in India responsible for economic development of the country that has established a national infrastructure of international standards that handles most of the securities held and settled in dematerialised form in the Indian capital market. | +| GDT | Global Dairy Trade | nan | +| CFFEX | China Financial Futures Exchange | Index and bond futures from CFFEX, with history spanning almost a decade for select futures. | +| CITYPOP | Thomas Brinkhoff: City Populations | Thomas Brinkhoff provides population data for cities and administrative areas in most countries. | +| BCHARTS | Bitcoin Charts Exchange Rate Data | Exchange rates for bitcoin against a large number of currencies, from all major bitcoin exchanges, including current and historical exchange rates. | +| LOCALBTC | Local Bitcoins | nan | +| JODI | JODI Oil World Database | JODI oil and gas data comes from over 100 countries consisting of multiple energy products and flows in various methods of measurement. | +| UENG | United Nations Energy Statistics | This database offers comprehensive global statistics on production, trade, conversion, and final consumption of new and renewable energy sources. | +| ULMI | United Nations Labour Market Indicators | This database offers comprehensive youth unemployment figures broken up by gender for all countries in the world. | +| MAURITIUSSE | Stock Exchange of Mauritius | Stock Exchange of Mauritius indices data. | +| UKRSE | Ukrainian Exchange | UKRSE presents the most current available data related to the largest stock exchanges in Ukraine. The exchange is located in Kiev and accounts for roughly three-quarters of Ukraines total equity trading volume | +| BITSTAMP | Bitstamp | Bitstamp is a trading platform for Bitcoin. | +| UNAE | United Nations National Accounts Estimates | This database offers global data on gross domestic product, gross national income, and gross value added by different sectors for all countries in the world. | +| UNAC | United Nations National Accounts Official Country Data | This database offers global data on national accounts, such as assets and liabilities of households, corporations and governments. | +| UTOR | United Nations World Tourism | This database offers comprehensive data on international tourism. Data includes number of tourist arrivals and tourism expenditures for all countries. | +| WFE | World Federation of Exchanges | A trade association of sixty publicly regulated stock, futures, and options exchanges that publishes data for its exchanges, like market capitalization. | +| FRBC | Federal Reserve Bank of Cleveland | The Federal Reserve Bank of Cleveland collects data from hundreds of financial institutions, including depository institutions, bank holding companies, and other entities that is used to assess financial institution conditions and also to glean insights into how the economy and financial system are doing. | +| UGEN | United Nations Gender Information | This database offers comprehensive global data on a wide range of gender-related indicators, covering demography, health, education and employment. | +| BITFINEX | Bitfinex | Bitfinex is a trading platform for Bitcoin, Litecoin and Darkcoin with many advanced features including margin trading, exchange and peer to peer margin funding. | +| UGHG | United Nations Greenhouse Gas Inventory | This database offers comprehensive global data on anthropogenic emissions of the six principal greenhouse gases. Data goes back to 1990. | +| UIST | United Nations Industrial Development Organization | This database offers global data on industrial development indicators, including output, employees, wages, value added for a wide range of industries. | +| PRAGUESE | Prague Stock Exchange | Price index data from the Prague Stock Exchange. | +| PFTS | PFTS Stock Exchange (Ukraine) | Index data from the PFTS Stock Exchange, the largest marketplace in Ukraine. | +| WARSAWSE | Warsaw Stock Exchange | WIG20 index has been calculated since April 16, 1994 based on the value of portfolio with shares in 20 major and most liquid companies in the WSE Main List. | +| TUNISSE | Tunis Stock Exchange | The main reference index of Tunis Stock Exchange. | +| FRKC | Federal Reserve Bank of Kansas City | FRKC is the regional central bank for the 10th District of the Federal Reserve, publishing data on banking in mostly agricultural transactions. | +| UENV | United Nations Environment Statistics | This database offers global data on water and waste related indicators, including fresh water supply and precipitation, and generation and collection of waste. | +| UFAO | United Nations Food and Agriculture | This database offers global food and agricultural data, covering crop production, fertilizer consumption, use of land for agriculture, and livestock. | +| TAIFEX | Taiwan Futures Exchange | Index and bond futures from TAIFEX, with history spanning over a decade for select futures. | +| GDAX | GDAX (Global Digital Asset Exchange) | GDAX is the world’s most popular place to buy and sell bitcoin. | +| ARES | Association for Real Estate Securitization | ARES protects investors, contributes to development of the real estate securitization product market, and facilitates expansion of the real estate investment market. | +| SHADOWS | Wu-Xia Shadow Federal Funds Rate | This dataset contains the three major indicators from the Wu-Xia papers which serve to identify the shadow rates on all three major banks. | +| NAAIM | NAAIM Exposure Index | The NAAIM Exposure Index represents the average exposure to US Equity markets reported by NAAIM members. | +| CBRT | Central Bank of the Republic of Turkey | CBRT is responsible for taking measures to sustain the stability of the financial system in Turkey. | +| CEGH | Central European Gas Hub | No description for this database yet. | +| FINRA | Financial Industry Regulatory Authority | Financial Industry Regulatory Authority provides short interest data on securities firms and exchange markets. | +| NASDAQOMX | NASDAQ OMX Global Index Data | Over 35,000 global indexes published by NASDAQ OMX including Global Equity, Fixed Income, Dividend, Green, Nordic, Sharia and more. Daily data. | +| EURONEXT | Euronext Stock Exchange | Historical stock data from Euronext, the largest European exchange. | +| UICT | United Nations Information and Communication Technology | This database offers comprehensive global data on information and communication technology, including telephone, cellular and internet usage for all countries. | +| USAID | U.S. Agency for International Development | US Agency for International Development provides a complete historical record of all foreign assistance provided by the United States to the rest of the world. | +| ZAGREBSE | Zagreb Stock Exchange | Croatias only stock exchange. It publishes data on the performance of its stock and bond indexes. | +| QUITOSE | Quito Stock Exchange (Ecuador) | The indexes of the national Stock Exchange of Ecuador. | +| ECBCS | European Commission Business and Consumer Surveys | Data in this database is derived from harmonized surveys for different sectors of the economies in the European Union (EU) and in the EU applicant countries. | +| PSE | Paris School of Economics | This database describes the distribution of top incomes in a growing number of countries. Numbers are derived using tax data. | +| MALTASE | Malta Stock Exchange | The Malta Stock Exchange carries out the role of providing a structure for admission of financial instruments to its recognised lists which may subsequently be traded on a regulated, transparent and orderly market place (secondary market).The main participants in the market are Issuers, Stock Exchange Members (stockbrokers), and the investors in general. | +| GPP | Global Petroleum Prices | No description for this database yet. | +| PPE | Polish Power Exchange (TGE) | No description for this database yet. | +| UKONS | United Kingdom Office of National Statistics | Data on employment, investment, housing, household expenditure, national accounts, and many other socioeconomic indicators in the United Kingdom. | +| NCDEX | National Commodity & Derivatives Exchange Limited (India) | A professionally managed on-line multi-commodity exchange in India | +| WSE | Warsaw Stock Exchange (GPW) | No description for this database yet. | +| TFX | Tokyo Financial Exchange | The Tokyo Financial Exchange is a futures exchange that primary deals in financial instruments markets that handle securities and market derivatives. | +| WGFD | World Bank Global Financial Development | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | +| CEPEA | Center for Applied Studies on Applied Economics (Brazil) | CEPEA is an economic research center at the University of Sao Paulo focusing on agribusiness issues, publishing price indices for commodities in Brazil. | +| SBJ | Statistics Bureau of Japan | A Japanese government statistical agency that provides statistics related to employment and the labour force. | +| WGEM | World Bank Global Economic Monitor | Data on global economic developments, with coverage of high-income, as well as developing countries. | +| WGDF | World Bank Global Development Finance | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | +| WWDI | World Bank World Development Indicators | Most current and accurate development indicators, compiled from officially-recognized international sources. | +| WESV | World Bank Enterprise Surveys | Company-level private sector data, covering business topics including finance, corruption, infrastructure, crime, competition, and performance measures. | +| WDBU | World Bank Doing Business | Data on business regulations and their enforcement for member countries and selected cities at the subnational and regional level. | +| OSE | Osaka Securities Exchange | The second largest securities exchange in Japan. Unlike the TSE, OSE is strongest in derivatives trading, the majority of futures and options in Japan. | +| RFSS | Russian Federation Statistics Service | The Russian governmental statistical agency that publishes social, economic, and demographic statistics for Russia at the national and local levels. | +| SHFE | Shanghai Futures Exchange | Commodities exchange for energy, metal, and chemical-related industrial products. A derivatives marketplace for many commodities futures. | +| WGEP | World Bank GEP Economic Prospects | Data on the short-, medium, and long-term outlook for the global economy and the implications for developing countries and poverty reduction. | +| USMISERY | United States Misery Index | Developed by economist Arthur Okun, the Misery Index is the unemployment rate added to the inflation rate. | +| WJKP | World Bank Jobs for Knowledge Platform | Indicators on labor-related topics. | +| WMDG | World Bank Millennium Development Goals | Data drawn from the World Development Indicators, reorganized according to the goals and targets of the Millennium Development Goals (MDGs). | +| WPOV | World Bank Poverty Statistics | Indicators on poverty headcount ratio, poverty gap, and number of poor at both international and national poverty lines. | +| EUREKA | Eurekahedge | A research company focused on hedge funds and other alternative investment funds. It publishes data on the performances of hedge funds. | +| MOFJ | Ministry of Finance Japan | Japanese government bond interest rate data, published daily by the Ministry of Finance. | +| PSX | Pakistan Stock Exchange | Daily closing stock prices from the Pakistan Stock Exchange. | +| SGX | Singapore Exchange | Asian securities and derivatives exchange that trades in equities for many large Singaporean and other Asian companies. Listed on its own exchange. | +| UIFS | United Nations International Financial Statistics | This database offers comprehensive data on international financial indicators, such as average earnings, bond yields, government revenues and expenditures. | +| UINC | United Nations Industrial Commodities | This database offers global data on production of industrial commodities, such as ores and minerals, food products, transportable goods, and metal products. | +| INSEE | National Institute of Statistics and Economic Studies (France) | INSEE is the national statistical agency of France. It collects data on Frances economy and society, such as socioeconomic indicators and national accounts. | +| SNB | Swiss National Bank | Central bank responsible for monetary policy and currency. Data on international accounts, interest rates, money supply, and other macroeconomic indicators. | +| ODE | Osaka Dojima Commodity Exchange | A non-profit commodity exchange in the Kansai region of Japan that trades in seven key agricultural commodities. | +| WGEN | World Bank Gender Statistics | Data describing gender differences in earnings, types of jobs, sectors of work, farmer productivity, and entrepreneurs’ firm sizes and profits. | +| WHNP | World Bank Health Nutrition and Population Statistics | Key health, nutrition and population statistics. | +| WIDA | World Bank International Development Association | Data on progress on aggregate outcomes for IDA (International Development Association) countries for selected indicators. | +| ECMCI | European Commission Monetary Conditions Index | Updated monthly, this database provides monetary conditions index values in the Euro zone. History goes back to 1999. | +| NBSC | National Bureau of Statistics of China | Statistics of China relating to finance, industry, trade, agriculture, real estate, and transportation. | +| MAS | Monetary Authority of Singapore | No description for this database yet. | +| MGEX | Minneapolis Grain Exchange | A marketplace of futures and options contracts for regional commodities that facilitates trade of agricultural indexes. | +| WWGI | World Bank Worldwide Governance Indicators | Data on aggregate and individual governance indicators for six dimensions of governance. | +| ISM | Institute for Supply Management | ISM promotes supply-chain management practices and publishes data on production and supply chains, new orders, inventories, and capital expenditures. | +| UKR | Ukrainian Exchange | No description for this database yet. | +| FRBNY | Federal Reserve Bank of New York | The FRBNY is the largest regional central bank in the US. Sets monetary policy for New York, most of Connecticut and New Jersey, and some territories. | +| FRBP | Federal Reserve Bank of Philadelphia | The FRBP is a regional central bank for the Federal Reserve. It publishes data on business confidence indexes, GDP, consumption, and other economic indicators. | +| FMSTREAS | US Treasury - Financial Management Service | The monthly receipts/outlays and deficit/surplus of the United States of America. | +| EIA | U.S. Energy Information Administration Data | US national and state data on production, consumption and other indicators on all major energy products, such as electricity, coal, natural gas and petroleum. | +| SOCSEC | Social Security Administration | Provides data on the US social security program, particularly demographics of beneficiaries; disabled, elderly, and survivors. | +| TFGRAIN | Top Flight Grain Co-operative | Cash price of corn and soybeans including basis to front month futures contract. | +| IRPR | Puerto Rico Institute of Statistics | Puerto Rico Institute of Statistics statistics on manufacturing. | +| BCHAIN | Blockchain | Blockchain is a website that publishes data related to Bitcoin, updated daily. | +| BITCOINWATCH | Bitcoin Watch | Bitcoin mining statistics. | +| ODA | IMF Cross Country Macroeconomic Statistics | IMF primary commodity prices and world economic outlook data, published by Open Data for Africa. Excellent cross-country macroeconomic data. | +| WADI | World Bank Africa Development Indicators | A collection of development indicators on Africa, including national, regional and global estimates. | +| WEDU | World Bank Education Statistics | Internationally comparable indicators on education access, progression, completion, literacy, teachers, population, and expenditures. | +| WGLF | World Bank Global Findex (Global Financial Inclusion database) | Indicators of financial inclusion measures on how people save, borrow, make payments and manage risk. | +| WWID | World Wealth and Income Database | The World Wealth and Income Database aims to provide open and convenient access to the most extensive available database on the historical evolution of the world distribution of income and wealth, both within countries and between countries. | +| BTER | BTER | Historical exchange rate data for crypto currencies. | +| CFTC | Commodity Futures Trading Commission Reports | Weekly Commitment of Traders and Concentration Ratios. Reports for futures positions, as well as futures plus options positions. New and legacy formats. | +| BOE | Bank of England Official Statistics | Current and historical exchange rates, interest rates on secured loans and time deposits, Euro-commercial paper rates, and yields on government securities. | +| EXMPL | Quandl Example Time-Series Data | An example time series database. | +| WORLDAL | Aluminium Prices | World Aluminium capacity and production in thousand metric tonnes. | +| WGC | Gold Prices | The World Gold Council is a market development organization for the gold industry. It publishes data on gold prices in different currencies. | +| MX | Canadian Futures | Montreal Exchange is a derivatives exchange that trades in futures contracts and options for equities, indices, currencies, ETFs, energy, and interest rates. | +| UMICH | Consumer Sentiment | The University of Michigan’s consumer survey - data points for the most recent 6 months are unofficial; they are sourced from articles in the Wall Street Journal. | +| JOHNMATT | Rare Metals | Current and historical data on platinum group metals such as prices, supply, and demand. | +| NAHB | US Housing Indices | Housing and economic indices for the United States. | +| RATEINF | Inflation Rates | Inflation Rates and the Consumer Price Index CPI for Argentina, Australia, Canada, Germany, Euro area, France, Italy, Japan, New Zealand and more. | +| RENCAP | IPOs | Data on the IPO market in the United States. | +| ML | Corporate Bond Yield Rates | Merrill Lynch, a major U.S. bank, publishes data on yield rates for corporate bonds in different regions. | +| MULTPL | S&P 500 Ratios | No description for this database yet. | +| RICI | Commodity Indices | Composite, USD based, total return index, representing the value of a basket of commodities consumed in the global economy. | +| AAII | Investor Sentiment | American Association of Individual Investor’s sentiment data. | +| BIS | Bank for International Settlements | BIS serves central banks with administration of monetary and financial stability, fosters international cooperation, and acts as bank for central banks. | +| BCB | Central Bank of Brazil Statistical Database | Brazilian macroeconomic data, covering public finances, national accounts, payment systems, inflation, exchange rates, trade, and international reserves. | +| BCRA | Central Bank of Argentina | The Central Bank of Argentina is responsible monetary policy and provides data on foreign exchange markets and key macroeconomic indicators. | +| FSE | Frankfurt Stock Exchange | Daily stock prices from the Frankfurt Stock Exchange | +| BLSN | BLS International | Import and export price statistics for various countries, published by the Bureau of Labor Statistics. | +| BLSP | BLS Productivity | US manufacturing, labor and business statistics, published by the Bureau of Labor Statistics. | +| FDIC | Federal Deposit Insurance Corporation | The FDIC is a federal insurer of bank deposits up to $250k and collects finance data on commercial banking and savings institutions. | +| BLSI | BLS Inflation & Prices | US national and state-level inflation data, published by the Bureau of Labor Statistics. | +| BLSE | BLS Employment & Unemployment | US national and state-level employment and unemployment statistics, published by the Bureau of Labor Statistics. | +| BLSB | BLS Pay & Benefits | US work stoppage statistics, published by the Bureau of Labor Statistics. | +| BP | Energy Production and Consumption | BP is a large energy producer and distributor. It provides data on energy production and consumption in individual countries and larger subregions. | +| LPPM | Platinum & Palladium Prices | Price data on the market-clearing level for Palladium and Platinum around the world. | +| CASS | Freight Indices | Since 1990, CASS provides monthly Cass Freight Index Reports on freight trends as they relate to other economic and supply chain indicators. | +| MORTGAGEX | ARM Indices | Historical housing data on ARM indexes. | +| BUCHARESTSE | Bucharest Stock Exchange | The Bucharest Stock Exchange publishes data on it activity in equity, rights, bonds, fund units, structured products, and futures contracts. | +| AMECO | European Commission Annual Macro-Economic Database | Annual macro-economic database of the European Commissions Directorate General for Economic and Financial Affairs (DG ECFIN). | +| ACC | American Chemistry Council | Chemical Activity Barometer (CAB) published by the American Chemistry Council (ACC). The CAB is an economic indicator that helps anticipate peaks and troughs in the overall US economy and highlights potential trends in other industries in the US. | +| ABMI | Asia Bond Market Initiative | Indicators of Chinese and Japanese bond markets, such as size and composition, market liquidity, yield returns, and volatility. | +| BITAL | Borsa Italiana | This database provides data on stock future contracts from the Borsa Italiana, now part of London Stock Exchange Group. | +| BANKRUSSIA | Bank of Russia | Primary indicators from the Bank of Russia, including data on the banking sector, money supply, financial markets and macroeconomic statistical data. | +| BOC | Bank of Canada Statistical Database | Economic, financial and banking data for Canada. Includes interest rates, inflation, national accounts and more. Daily updates. | +| HKEX | Hong Kong Exchange | Hong Kong Exchange stock prices, historical divided futures, etc. updated daily. | +| AMFI | Association of Mutual Funds in India | This database represents fund information from The Association of Mutual Funds in India. | +| BDM | Bank of Mexico | The Bank of Mexico is responsible for monetary policy and the national currency (peso), and provides data on accounts and all macroeconomic variables. | +| BATS | BATS U.S. Stock Exchanges | Bats is an equities market operator in the U.S., operating four equities exchanges — BZX Exchange, BYX Exchange, EDGA Exchange, and EDGX Exchange | +| BSE | Bombay Stock Exchange | End of day prices, indices, and additional information for companies trading on the Bombay Stock Exchange in India. | +| FRED | Federal Reserve Economic Data | Growth, employment, inflation, labor, manufacturing and other US economic statistics from the research department of the Federal Reserve Bank of St. Louis. | +| FMAC | Freddie Mac | Data from Freddie Mac’s Primary Mortgage Market Survey and other region specific historical mortgage rates. | +| EUREX | EUREX Futures Data | Index, rate, agriculture and energy futures from EUREX, Europes largest futures exchange, with history spanning a decade for select futures. | +| ECB | European Central Bank | The central bank for the European Union oversees monetary policy and the Euro, and provides data on related macroeconomic variables. | +| BOF | Bank of France | The Banque de France is responsible for monetary policy through policies of the European System of Central Banks and providing data on key economic indictors. | +| BELGRADESE | Belgrade Stock Exchange | Belgrade Stock Exchange data, updated daily. | +| CHRIS | Wiki Continuous Futures | Continuous contracts for all 600 futures on Quandl. Built on top of raw data from CME, ICE, LIFFE etc. Curated by the Quandl community. 50 years history. | +| BOJ | Bank of Japan | nan | +| USTREASURY | US Treasury | The U.S. Treasury ensures the nations financial security, manages the nations debt, collects tax revenues, and issues currency, provides data on yield rates. | +| LBMA | London Bullion Market Association | An international trade association in the London gold and silver market, consisting of central banks, private investors, producers, refiners, and other agents. | +| PERTH | Perth Mint | The Perth Mint’s highs, lows and averages of interest rates and commodities prices, updated on a monthly basis. | +| ZILLOW2 | Zillow Real Estate Research | Home prices and rents by size, type and tier; housing supply, demand and sales. Sliced by zip code, neighbourhood, city, metro area, county and state. | \ No newline at end of file From 120518220ccd2836d8b6b73e2bb137be4d75d877 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Sun, 28 Apr 2019 16:05:18 +0800 Subject: [PATCH 337/421] New translations usecase_data_analysis.md (Chinese Simplified) --- .../zh-CN/usecase_data_analysis.md | 482 +++++++++--------- 1 file changed, 242 insertions(+), 240 deletions(-) diff --git a/website/translated_docs/zh-CN/usecase_data_analysis.md b/website/translated_docs/zh-CN/usecase_data_analysis.md index 4b95703..37b33f4 100644 --- a/website/translated_docs/zh-CN/usecase_data_analysis.md +++ b/website/translated_docs/zh-CN/usecase_data_analysis.md @@ -3,296 +3,298 @@ id: usecase_data_analysis title: Data Analysis --- -## 关于 Quandl +# Financial data analysis based on Quandl -Quandl 是一个针对金融投资行业的大数据平台,其数据来源包括联合国、世界银行、中央银行等公开数据,核心财务数据来自 CLS 集团,Zacks 和 ICE 等,所有的数据源自 500 多家发布商, 是为投资专业人士提供金融,经济和替代数据的首选平台,拥有海量的经济和金融数据。 +## About Quandl -## Quandl 数据索引 +Quandl is a big data platform for the financial investment industry. Its data sources include public data such as the United Nations, the World Bank, and the Central Bank. The core financial data comes from CLS Group, Zacks and ICE. All data comes from more than 500 publishers. It is the preferred platform for investment professionals to provide financial, economic and alternative data with vast economic and financial data. -### CovenantSQL 使用简介 +## Quandl Data Index -首先,我们已基于 Quandl 的开放 API 将数据存放在 CovenantSQL 中,首先应该浏览一下 CovenantSQL 的使用介绍来熟悉一下如何连接并且使用 CovenantSQL。 +### Introduction to CovenantSQL -现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 +First, we have stored the data in CovenantSQL based on Quandl's open API. Next, you should take a look at the introduction of CovenantSQL to know how to connect and use CovenantSQL. -具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) +Now due to client compatibility issues, please use our HTTP service to query the Quandl database directly. This document will be updated as soon as possible after the current cql client is compatible. -所需参数: +Use CovenantSQL specifically through the HTTP service. Please refer to the Python driver documentation and the NodeJS driver documentation. + +Required parameters: host: 'e.morenodes.com' - port: 11108 + port: 11111 database: '057e55460f501ad071383c95f691293f2f0a7895988e22593669ceeb52a6452a' -### 数据使用方法 +### How to use CQL-Quandl -Quandl 数据分为表以及子表两层索引 +Quandl data is divided into tables and sub-tables -数据库中,表名为`quandl_` + `database_code`为完整表名 +In the database, the table name is `quandl_ + database_code` for the full table name -通过查询表名来查看表的内容 +View the contents of the table by querying the table name -具体使用时,需要结合`quandl_updateindex` 这张索引表来使用,(查询索引表时,请务必 limit 小于 10 万,因为全表数据量过大) +For specific use, you need to use the `quandl_updateindex` index table to use it. (When querying the index table, be sure to limit less than 100,000 because the full data is too large) -使用时,请使用 where 语句限定`quandlcode`字段来查询表中的子表数据。 +Please using the `where` statement to qualify the `quandlcode` field to query the sub table data in the table. -### 查询示例 +## Example -1. 我们想要查询 欧盟委员会年度宏观经济数据库 的数据,我们找到其第一层索引的 `databasecode` 为`quandl_ameco`,于是,我们可以查询其第二层索引,用以下 SQL 命令行: - - `select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000` +1. We want to query the data of the European Commission's annual macroeconomic database. We find the database code of its first index is `quandl_ameco`, so we can query its second index, using the following SQL command line: -2. 然后通过第三列,我们可以查看`quandlcode`对应的描述 - - 比如 AMECO/ALB_1_0_0_0_AAGE 对应的就是阿尔巴尼亚的进出口相关信息,时间从 1960 到 1988。 - - Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania - - 于是,我们可以用以下方式把这个子表给查询出来 - - `select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000` +```SQL + select * from quandl_updateindex where databasecode like 'ameco' group by quandlcode limit 10000; + ``` + +2. Then through the third column, we can see the description corresponding to the `quandlcode` -3. 注意:如果内容整列为 null 的,属于表结构本身不存在的字段,可以自行去除。 + For example, `AMECO/ALB_1_0_0_0_AAGE` corresponds to the import and export information of Albania from 1960 to 1988. -## Quandl 数据 Excel 插件使用说明 + Average share of imports and exports of goods in world trade excluding intra EU trade; Foreign trade statistics (1960-1998 Former EU-15) - Albania -您可以下载 Quandl 数据 Excel 插件,无须安装,请解压到任意文件夹中。此插件目前仅支持 Office 2010 以及以上版本,office 2007 以及以下版本目前暂不支持。 + So, we can query this subtable in the following way. -### 配置 Excel 插件 + ```SQL + select * from quandl_ameco where quandlcode like 'AMECO/ALB_1_0_0_0_AAGE' limit 10000; + ``` -解压下载后压缩包,在文件夹中有两个.xll 文件,`ClassLibrary7-AddIn.xll` 以及 `ClassLibrary7-AddIn64.xll` 文件,这两个文件分别对应 32 位的 Excel 与 64 位的 Excel,请根据您的电脑配置使用对应插件。 +3. Note: If the content of the content is null, it belongs to the field that does not exist in the table structure itself, you can remove it yourself. -#### 修改 xml 配置 +# Quandl Data Excel Plugin Instructions -每个 `.xll` 文件对应一个 `.config` 的配置文件,也就是 `ClassLibrary7-AddIn.xll.config` 和`ClassLibrary7-AddIn64.xll.config`,为如下 xml 配置: +You can download the Quandl Data Excel plugin without having to install it, unzip it into any folder. This plugin currently only supports Office 2010 and above, and Office 2007 and below are currently not supported. + +## Configuring the Excel plugin + +Unzip the downloaded package. There are two .xll files in the folder, `ClassLibrary7-AddIn.xll` and `ClassLibrary7-AddIn64.xll` files. These two files correspond to 32-bit Excel and 64-bit Excel respectively. Please refer to your The computer configuration uses the corresponding plugin. + +### Modify the xml configuration + +Each .xll file corresponds to a .config configuration file, which is `ClassLibrary7-AddIn.xll.config` and `ClassLibrary7-AddIn64.xll.config`, configured for the following xml: ```xml - - - + + + ``` -其中有如下配置需要修改,并保存: +The following configuration needs to be modified and saved: -- certpath: 请填写 `read.data.thunderdb.io.pfx` 证书的绝对路径 +`Certpath`: Please fill in the absolute path of the `read.data.covenantsql.io.pfx` certificate -#### 安装插件 +### Plugin installation -有两种办法使用此 Excel 插件 +There are two ways to use this Excel plugin -1. 直接双击对应的 32 位或 64 位 Excel 的 xll 文件打开 +1. Double-click the corresponding 32-bit or 64-bit Excel xll file to open it. ![quandl_ext_1](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_1.png) -如果弹出如上对话框,选择第一个: `仅为本回话启用此加载项`。然后新建一个 Excel 表格,如果在 Excel 的上方选项卡中看到 CovenantSQL,说明插件加载成功。 +If the above dialog box shows up, select the first one: Enable this add-on only for this callback. Then create a new Excel table. If you see CovenantSQL in the upper tab of Excel, the plugin is loaded successfully. -2. 打开 Excel,然后依次选择 `文件 — 选项 — 加载项`,管理选择 Excel 加载项,点击转到然后浏览选择解压后的对应版本的 `.xll` 文件,然后点击 `确定`,在选项卡中如果成功加载出 CovenantSQL 即为成功加载,如下图: +2. Open Excel, then select File - Options - Add-ons, Manage Select Excel Add-Ins, click Go and browse to select the .xll file for the corresponding version after decompression, and then click OK. If you successfully load CovenantSQL in the tab, Successfully loaded, as shown below: ![quandl_ext_2](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_2.png) -#### 使用插件 - -选择 CovenantSQL 的选项卡可以看到 Quandl 数据查询,点击 Quandl 数据查询,会弹出一个窗体如下图所示: - -![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3.png) +### How to use plugin -- 其中红色框住的列表部分是一级目录,下方则是所选项的具体描述 +Select the CovenantSQL tab to see the Quandl data query. Click on the Quandl data query and a pop-up will appear as shown below: -- 绿色按钮是通过选择的一级目录来查询二级目录。这里查询时间会随着所查询二级目录的大小以及用户自身的网络速度等因素而不同,可能查询时间会超过 1 分钟,请耐心等待。 +![quandl_ext_3](https://raw.githubusercontent.com/CovenantSQL/cql-excel-extension/master/refs/quandl_ext_3_en.png) -- 黄色部分左边的列表是二级目录,右边的窗体则为列表项所选择的表的描述。 +- The part of the list that is framed by red is the first-level directory, and the lower part is the specific description of the selected item. +- The green button queries the se condary directory by selecting the primary directory. The query time will vary depending on the size of the secondary directory being queried and the user's own network speed. The query time may exceed 1 minute. Please be patient. +- The list on the left of the yellow part is the secondary directory, and the form on the right is the description of the table selected by the list item. -- 蓝色部分是导出数据的可选项 +- The blue part is an option to export data - - Limit Number 是一次导出的最多数据条数,默认为 10000 条,最大值可填写 100000 - - Offset Number 是从数据库的第几条开始导出,因为之前会限定条数,例如我们之前导出了 10000 条数据,但是明显数据还没有导出全部,我们可以使用此功能选择 offset 10000 来从第 10000 条开始导出(注:数据库的计数从 0 开始,所以前 10000 条为 0-9999) - -现在,您即可在 Excel 中方便的调用存在 CovenantSQL 上的 Quandl 数据。 - -## 附件表 - -| DataBase | 名称 | 描述 | -| ------------ | ------------------------ | ------------------------------------------------------------------------------------------- | -| BUNDESBANK | 德意志联邦银行数据仓库 | 有关德国经济,货币和资本市场,公共财政,银行,家庭,欧元区总量,贸易和外债的数据。 | -| URC | 独角兽研究公司数据 | 纽约证券交易所,美国证券交易所和纳斯达克证券交易所的预付和下跌数据。从各种公开来源和报告中值。 | -| DCE | 大连商品交易所数据 | 来自DCE的农业和商品期货,历史跨越了近十年的特定期货。 | -| WFC | 富国银行住房抵押贷款数据 | 该数据库提供富国银行(Wells Fargo Bank)分部Wells Fargo Home Mortgage的抵押贷款购买和再融资利率。 | -| USDAFNS | 美国农业部食品与营养服务项目数据 | 食品和营养服务局为低收入家庭和儿童管理联邦营养援助计划。成本和参与率数据。 | -| LJUBSE | 卢布尔雅那证券交易所数据 | 该数据库包含卢布尔雅那股票交易所指数,总部位于斯洛文尼亚的卢布尔雅那。 | -| TOCOM | 东京商品交易所数据 | 来自东京商品交易所(TOCOM)的农业和商品期货,历史跨越了近十年的特定期货。 | -| WCSC | 世界银行企业积分卡数据 | 该数据库旨在提供世界银行集团在消除极端贫困和促进共同繁荣方面的表现的战略概述。 | -| CMHC | 加拿大住房抵押贷款公司 | CMHC是一家政府所有的公司,为加拿大公民提供经济适用房,并收集价格,建筑和供应等数据。 | -| WGEC | 世界银行全球经济监测商品数据(GEM) | 包含1960年至今的商品价格和指数的数据。 | -| FED | 美联储数据公布 | 美国官方关于货币供应量,利率,抵押贷款,政府财政,银行资产和债务,汇率,工业生产的数据。 | -| WPSD | 世界银行公共部分支出数据 | 由世界银行和国际货币基金组织共同开发的数据,汇集了详细的公共部门政府债务数据。 | -| UGID | 联合国全球指标 | 该数据库提供广泛的全球指标,涵盖人口,公共卫生,就业,贸易,教育,通货膨胀和外债。 | -| RBA | 澳大利亚储备银行数据 | 中央银行和货币当局,监管银行业,设定利率,并为政府债务提供服务。关键经济指标数据。 | -| UCOM | 联合国商品贸易数据 | 该数据库提供有关食品,活体动物,药品,金属,燃料和机械等商品进出口的全面综合数据。 | -| SIDC | 太阳影响数据分析中心数据 | SIDC主持从1700年开始的太阳活动数据,特别是太阳黑子活动。 | -| ZCE | 郑州商品交易所数据 | 来自ZCE的农业和商品期货,历史跨越了近十年的特定期货。 | -| USDAFAS | 美国农业部外国农业服务数据(FAS) | 美国农业部外国农业服务局将美国农业与世界市场联系起来。它提供了国外生产和出口的统计数据。 | -| OECD | 世界经济合作与发展组织数据 | 促进经济福利的发达国家国际组织。从成员和其他人收集数据以提出政策建议。 | -| OPEC | 欧佩克数据 | 国际组织和经济卡特尔监督伊拉克,伊朗,沙特阿拉伯和委内瑞拉等石油生产国的政策、油价数据。 | -| MCX | 印度多种商品交易所数据 | 印度最大的商品交易所,为金属,能源和农业期货交易提供服务。世界第三大合约和交易量交易所。 | -| ECONOMIST | 经济学人 - 巨无霸指数 | 巨无霸指数是由经济学家于1986年发明的,是一个轻松的指南,指出货币是否处于“正确”水平。它基于购买力平价理论(PPP)。 | -| NSDL | 国家证券存管有限公司(印度)数据 | 在印度存放负责该国经济发展的国家,该国家建立了国际标准的国家基础设施,处理在印度资本市场以非物质形式持有和结算的大部分证券。 | -| GDT | 全球乳品贸易数据 | nan | -| CFFEX | 中国金融期货交易所数据 | 来自CFFEX的指数和债券期货,对于特定期货的历史跨越近十年。 | -| CITYPOP | Thomas Brinkhoff的城市人口数据 | Thomas Brinkhoff提供了大多数国家城市和行政区域的人口数据。 | -| BCHARTS | 比特币图表汇率数据 | 来自所有主要比特币交易所的比特币兑换大量货币的汇率,包括当前和历史汇率。 | -| LOCALBTC | Local Bitcoins数据 | nan | -| JODI | JODI石油世界数据库 | JODI石油和天然气数据来自100多个国家,包括多种能源产品和各种计量方法。 | -| UENG | 联合国能源统计数据 | 该数据库提供有关新能源和可再生能源的生产,贸易,转换和最终消费的全面统计数据。 | -| ULMI | 联合国劳工市场指标 | 该数据库为世界上所有国家提供了按性别划分的全面青年失业数字。 | -| MAURITIUSSE | 毛里求斯证券交易所数据 | 毛里求斯证券交易所指数数据。 | -| UKRSE | 乌克兰交易所数据 | UKRSE提供与乌克兰最大证券交易所相关的最新数据。该交易所位于基辅,约占乌克兰总股本交易量的四分之三 | -| BITSTAMP | Bitstamp数据 | Bitstamp是一个比特币的交易平台。 | -| UNAE | 联合国国民账户估算数据 | 该数据库提供了全球所有国家不同部门的国内生产总值,国民总收入和总增加值的全球数据。 | -| UNAC | 联合国国民账户官方国家数据 | 该数据库提供有关国民账户的全球数据,例如家庭,公司和政府的资产和负债。 | -| UTOR | 联合国世界旅游业数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | -| WFE | 世界交易所联合会数据 | 该数据库提供有关国际旅游的综合数据。数据包括所有国家的旅游人数和旅游支出。 | -| FRBC | 克利夫兰联邦储备银行数据 | 克利夫兰联邦储备银行从数百家金融机构收集数据,包括存款机构,银行控股公司和其他用于评估金融机构状况的实体,以及收集经济和金融体系运作方式的见解。 | -| UGEN | 联合国性别信息 | 该数据库提供关于各种与性别有关的指标的全面综合数据,涵盖人口,卫生,教育和就业。 | -| BITFINEX | Bitfinex数据 | Bitfinex是比特币,莱特币和Darkcoin的交易平台,具有许多先进功能,包括保证金交易,交易所和点对点保证金融资。 | -| UGHG | 联合国温室气体清单 | 该数据库提供有关六种主要温室气体人为排放的全面综合数据。数据可以追溯到1990年。 | -| UIST | 联合国工业发展组织数据 | 该数据库提供有关工业发展指标的全球数据,包括产量,员工,工资,各种行业的增加值。 | -| PRAGUESE | 布拉格证券交易所数据 | 布拉格证券交易所的价格指数数据。 | -| PFTS | PFTS证券交易所(乌克兰)数据 | 来自PFTS证券交易所的指数数据,这是乌克兰最大的市场。 | -| WARSAWSE | 华沙证券交易所数据 | WIG20指数自1994年4月16日起根据WSE主要清单中20家最主要和最具流动性公司的股票价值计算。 | -| TUNISSE | 突尼斯证券交易所数据 | 突尼斯证券交易所的主要参考指数。 | -| FRKC | 堪萨斯城联邦储备银行数据 | FRKC是美联储第10区的区域中央银行,主要发布农业交易中的银行业务数据。 | -| UENV | 联合国环境统计数据 | 该数据库提供有关水和废物相关指标的全球数据,包括淡水供应和降水,以及废物的产生和收集。 | -| UFAO | 联合国粮食和农业数据 | 该数据库提供全球粮食和农业数据,包括作物生产,化肥消费,农业用地和牲畜用途。 | -| TAIFEX | 台湾期货交易所数据 | 来自TAIFEX的指数和债券期货,其历史跨越了十多年的特定期货。 | -| GDAX | GDAX(全球数字资产交易所)数据 | GDAX是世界上最受欢迎的买卖比特币的地方。 | -| ARES | 房地产证券化协会数据 | ARES保护投资者,有助于房地产证券化产品市场的发展,并促进房地产投资市场的扩张。 | -| SHADOWS | 影子联邦基金利率模型数据 | 该数据集包含 吴-侠 论文中关于影子联邦基金的三个主要指标,用于识别所有三大银行的影子利率。 | -| NAAIM | 全国积极投资管理者协会头寸指数 | NAAIM暴露指数代表NAAIM成员报告的美国股票市场的平均风险敞口。 | -| CBRT | 土耳其共和国中央银行数据 | CBRT负责采取措施维持土耳其金融体系的稳定。 | -| CEGH | 中欧天然气中心数据 | nan | -| FINRA | 美国金融业监管局数据 | 金融业监管局提供证券公司和交易所市场的短期利息数据。 | -| NASDAQOMX | 纳斯达克OMX全球指数数据 | 纳斯达克OMX发布的全球指数超过35,000种,包括全球股票,固定收益,股息,绿色,北欧,伊斯兰教等。每日数据。 | -| EURONEXT | 泛欧证券交易所数据 | 欧洲最大的交易所Euronext的历史股票数据。 | -| UICT | 联合国信息和通信技术数据 | 该数据库提供有关信息和通信技术的全面全球数据,包括所有国家的电话,蜂窝和互联网使用情况。 | -| USAID | 美国国际开发署数据 | 美国国际开发署提供了美国向世界其他地方提供的所有外国援助的完整历史记录。 | -| ZAGREBSE | 萨格勒布证券交易所数据 | 克罗地亚唯一的证券交易所。它发布有关其股票和债券指数表现的数据。 | -| QUITOSE | 基多证券交易所(厄瓜多尔)数据 | 厄瓜多尔国家证券交易所的指数。 | -| ECBCS | 欧盟委员会商业和消费者调查 | 该数据库中的数据来自欧盟(EU)和欧盟申请国的不同经济部门的统一调查。 | -| PSE | 巴黎经济学院数据 | 该数据库描述了越来越多国家的最高收入分配。数字是使用税收数据得出的。 | -| MALTASE | 马耳他证券交易所数据 | 马耳他证券交易所发挥作用,为其认可的名单提供金融工具的结构,随后可在受监管,透明和有序的市场(二级市场)进行交易。市场的主要参与者是发行人,股票交易所会员(股票经纪人)和投资者一般。 | -| GPP | 全球石油价格 | nan | -| PPE | 波兰电力交易所(TGE)数据 | nan | -| UKONS | 英国国家统计局数据 | 关于英国就业,投资,住房,家庭支出,国民账户和许多其他社会经济指标的数据。 | -| NCDEX | 国家商品及衍生品交易所(印度)数据 | 印度专业管理的在线多商品交易所 | -| WSE | 华沙证券交易所(GPW)数据 | nan | -| TFX | 东京金融交易所数据 | 东京金融交易所是一个期货交易所,主要交易金融工具市场,处理证券和市场衍生品。 | -| WGFD | 世界银行全球金融发展数据 | 有关金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | -| CEPEA | 应用经济学应用研究中心(巴西)数据 | CEPEA是圣保罗大学的一个经济研究中心,专注于农业企业问题,发布巴西商品价格指数。 | -| SBJ | 日本统计局数据 | 日本政府统计机构,提供有关就业和劳动力的统计数据。 | -| WGEM | 世界银行全球经济监测 | 关于全球经济发展的数据,涵盖高收入国家和发展中国家。 | -| WGDF | 世界银行全球发展金融 | 关于金融系统特征的数据,包括金融机构和市场的规模,使用,获取,效率和稳定性的衡量标准。 | -| WWDI | 世界银行世界发展指标 | 最新和最准确的发展指标,由官方认可的国际来源汇编而成。 | -| WESV | 世界银行企业调查 | 公司级私营部门数据,涵盖金融,腐败,基础设施,犯罪,竞争和绩效衡量等业务主题。 | -| WDBU | 世界银行存续商业数据 | 关于成员国和地方和区域一级选定城市的商业法规及其执法的数据。 | -| OSE | 大阪证券交易所数据 | 日本第二大证券交易所。与东京证券交易所不同,OSE在衍生品交易方面表现最为强劲,是日本的大多数期货和期权。 | -| RFSS | 俄罗斯联邦统计局数据 | 俄罗斯政府统计机构,负责在国家和地方层面发布俄罗斯的社会,经济和人口统计数据。 | -| SHFE | 上海期货交易所数据 | 大宗商品交换能源,金属和化学相关的工业产品。许多商品期货的衍生品市场。 | -| WGEP | 世界银行全球环境规划经济前景数据 | 关于全球经济的短期,中期和长期前景以及对发展中国家和减贫的影响的数据。 | -| USMISERY | 美国痛苦指数 | 由经济学家亚瑟·奥肯(Arthur Okun)开发的苦难指数是失业率加上通胀率。 | -| WJKP | 世界银行知识平台工作数据 | 与劳工有关的主题指标。 | -| WMDG | 世界银行千年发展目标数据 | 根据千年发展目标(MDGs)的目标和指标重新组织的世界发展指标数据。 | -| WPOV | 世界银行贫困统计 | 贫困人口比率,贫困差距以及国际和国家贫困线贫困人口数量的指标。 | -| EUREKA | Eurekahedge数据 | 一家研究公司专注于对冲基金和其他另类投资基金。它公布了对冲基金业绩的数据。 | -| MOFJ | 日本财务省数据 | 日本政府债券利率数据,由财政部每日公布。 | -| PIKETTY | Thomas Piketty数据 | “21世纪资本”中的收入和财富数据,哈佛大学出版社,2014。 | -| PSX | 巴基斯坦证交所数据 | 巴基斯坦证券交易所的股票收盘价格。 | -| SGX | 新加坡交易所数据 | 亚洲证券和衍生品交易所为许多大型新加坡和其他亚洲公司进行股票交易。在自己的交易所上市。 | -| UIFS | 联合国国际金融统计 | 该数据库提供有关国际财务指标的综合数据,如平均收入,债券收益率,政府收入和支出。 | -| UINC | 联合国工业商品数据 | 该数据库提供有关工业商品生产的全球数据,如矿石和矿物,食品,可运输货物和金属产品。 | -| INSEE | 国家统计和经济研究所(法国)数据 | INSEE是法国的国家统计机构。它收集有关法国经济和社会的数据,如社会经济指标和国民账户。 | -| SNB | 瑞士国家银行数据 | 中央银行负责货币政策和货币。有关国际账户,利率,货币供应和其他宏观经济指标的数据。 | -| ODE | 大阪道岛商品交易所数据 | 日本关西地区的一个非营利性商品交易所,交易七种主要农产品。 | -| WGEN | 世界银行性别统计 | 描述收入,工作类型,工作部门,农民生产率以及企业家公司规模和利润的性别差异的数据。 | -| WHNP | 世界银行健康营养与人口统计 | 关键的健康,营养和人口统计数据。 | -| WIDA | 世界银行国际发展协会 | 关于选定指标的IDA(国际开发协会)国家总体成果进展情况的数据。 | -| ECMCI | 欧盟委员会货币状况指数 | 每月更新,此数据库提供欧元区的货币状况指数值。历史可以追溯到1999年。 | -| NBSC | 中国国家统计局数据 | 中国有关金融,工业,贸易,农业,房地产和交通运输的统计数据。 | -| MAS | 新加坡金融管理局数据 | nan | -| MGEX | 明尼阿波利斯谷物交易所数据 | 促进农业指数贸易的区域商品期货和期权合约市场。 | -| WWGI | 世界银行全球治理指标 | 六个治理层面的总体和个别治理指标数据。 | -| ISM | 供应管理研究所 | ISM促进供应链管理实践,并发布有关生产和供应链,新订单,库存和资本支出的数据。 | -| UKR | 乌克兰交易所数据 | nan | -| FRBNY | 纽约联邦储备银行数据 | FRBNY是美国最大的区域中央银行。为纽约,康涅狄格州和新泽西州的大部分地区以及一些地区设定货币政策。 | -| FRBP | 费城联邦储备银行数据 | FRBP是美联储的区域中央银行。它发布有关商业信心指数,GDP,消费和其他经济指标的数据。 | -| FMSTREAS | 美国财政部 - 财务管理处数据 | 美利坚合众国的月收入/支出和赤字/盈余。 | -| EIA | 美国能源信息管理局数据 | 美国国家和州有关所有主要能源产品(如电力,煤炭,天然气和石油)的生产,消费和其他指标的数据。 | -| SOCSEC | 美国社会保障局数据 | 提供有关美国社会保障计划的数据,特别是受益人的人口统计数据;残疾人,老人和幸存者。 | -| TFGRAIN | 顶级飞行谷物合作社数据 | 玉米和大豆的现货价格,包括前月期货合约的基础。 | -| IRPR | 波多黎各统计研究所数据 | 波多黎各统计研究所制造业统计数据。 | -| BCHAIN | blockchain.com数据 | Blockchain是一个发布与比特币相关的数据的网站,每日更新。 | -| BITCOINWATCH | Bitcoin Watch数据 | 比特币采矿统计。 | -| ODA | 国际货币基金组织跨国宏观经济统计 | 国际货币基金组织的初级商品价格和世界经济展望数据,由非洲开放数据公布。优秀的跨国宏观经济数据。 | -| WADI | 世界银行非洲发展指标 | 关于非洲的一系列发展指标,包括国家,区域和全球估计数。 | -| WEDU | 世界银行教育统计 | 关于教育机会,进展,完成,扫盲,教师,人口和支出的国际可比指标。 | -| WGLF | 世界银行全球Findex(全球金融包容性数据库) | 关于人们如何储蓄,借贷,支付和管理风险的金融包容性指标。 | -| WWID | 世界财富和收入数据库 | 世界财富和收入数据库旨在提供开放和便捷的途径,以获取有关国家内部和国家之间世界收入和财富分配历史演变的最广泛的现有数据库。 | -| BTER | 比特儿数据 | 加密货币的历史汇率数据。 | -| CFTC | 商品期货交易委员会报告 | 交易员和集中比率的每周承诺。期货头寸以及期货加期权头寸的报告。新旧格式。 | -| BOE | 英格兰银行官方统计 | 当前和历史汇率,担保贷款和定期存款利率,欧元商业票据利率和政府证券收益率。 | -| EXMPL | Quandl时间序列数据示例 | 一个时间序列数据库示例。 | -| WORLDAL | 铝价格 | 世界铝产能和产量(千公吨)。 | -| WGC | 黄金价格 | 世界黄金协会是黄金行业的市场开发组织。它以不同货币发布黄金价格数据。 | -| MX | 加拿大期货数据 | 蒙特利尔交易所是一家衍生品交易所,交易期货合约以及股票,指数,货币,ETF,能源和利率的期权。 | -| UMICH | 消费者情绪 | 密歇根大学的消费者调查 - 最近6个月的数据点是非官方的;它们来自华尔街日报的文章。 | -| JOHNMATT | 稀有金属价格数据 | 关于铂族金属的当前和历史数据,如价格,供应和需求。 | -| NAHB | 美国住房指数 | 美国的住房和经济指数。 | -| RATEINF | 通货膨胀率 | 阿根廷,澳大利亚,加拿大,德国,欧元区,法国,意大利,日本,新西兰等国的通货膨胀率和消费物价指数CPI。 | -| RENCAP | IPO数据 | 有关美国IPO市场的数据。 | -| ML | 公司债券收益率数据 | 美林(Merrill Lynch)是美国一家大型银行,它发布了不同地区公司债券收益率的数据。 | -| MULTPL | S&P 500 | nan | -| RICI | 商品指数 | 综合,以美元为基础的总回报指数,代表全球经济中消费的一篮子商品的价值。 | -| AAII | 投资者情绪 | 美国个人投资者协会的情绪数据。 | -| BIS | 国际清算银行数据 | 国际清算银行为中央银行提供货币和金融稳定管理,促进国际合作,并作为中央银行的银行。 | -| BCB | 巴西中央银行统计数据库 | 巴西宏观经济数据,涵盖公共财政,国民账户,支付系统,通货膨胀,汇率,贸易和国际储备。 | -| BCRA | 阿根廷中央银行数据 | 阿根廷中央银行负责货币政策,提供外汇市场数据和主要宏观经济指标。 | -| FSE | 法兰克福证券交易所 | 法兰克福证券交易所的每日股票价格 | -| BLSN | 劳工统计局国际数据 | 各国的进出口价格统计,由劳工统计局公布。 | -| BLSP | 劳工统计局生产力数据 | 美国制造业,劳务和商业统计,由劳工统计局公布。 | -| FDIC | 联邦存款保险公司数据 | FDIC是一家银行存款高达25万美元的联邦保险公司,负责收集商业银行和储蓄机构的财务数据。 | -| BLSI | 美国劳工统计局通货膨胀和价格统计 | 美国国家和州一级的通胀数据,由劳工统计局公布。 | -| BLSE | 美国劳工统计局就业与失业统计 | 美国国家和州一级的就业和失业统计数据,由劳工统计局公布。 | -| BLSB | 美国劳工统计局薪酬福利统计 | 由劳工统计局公布的美国停工统计数据。 | -| BP | BP能源生产和消费数据 | BP是一家大型能源生产商和分销商。它提供了各个国家和较大次区域的能源生产和消费数据。 | -| LPPM | 白金和钯价格数据 | 全球钯金和铂金市场清算价格数据。 | -| CASS | 运费指数 | 自1990年以来,CASS每月提供与其他经济和供应链指标相关的货运趋势的CASS运费指数报告。 | -| MORTGAGEX | 可调利率抵押贷款指数 | ARM索引的历史住房数据。 | -| BUCHARESTSE | 布加勒斯特证券交易所数据 | 布加勒斯特证券交易所发布股票,权利,债券,基金单位,结构性产品和期货合约活动数据。 | -| AMECO | 欧盟委员会年度宏观经济数据库 | 欧洲委员会经济和财政事务总局(DG ECFIN)年度宏观经济数据库。 | -| ACC | 美国化学理事会数据 | 化学活性晴雨表(CAB)由美国化学理事会(ACC)出版。 CAB是一个经济指标,有助于预测整个美国经济的高峰和低谷,并突出了美国其他行业的潜在趋势。 | -| ABMI | 亚洲债券市场计划 | 中国和日本债券市场的指标,如规模和构成,市场流动性,收益率收益率和波动率。 | -| BITAL | 意大利证交所数据 | 该数据库提供了Borsa Italiana(现为伦敦证券交易所集团的一部分)的股票期货合约数据。 | -| BANKRUSSIA | 俄罗斯银行数据 | 俄罗斯银行的主要指标,包括银行业,货币供应量,金融市场和宏观经济统计数据。 | -| BOC | 加拿大银行统计数据库 | 加拿大的经济,金融和银行数据。包括利率,通货膨胀,国民账户等。每日更新。 | -| HKEX | 香港交易所数据 | 香港交易所股票价格,历史分割期货等每日更新。 | -| AMFI | 印度共同基金协会数据 | 该数据库代表印度共同基金协会的基金信息。 | -| BDM | 墨西哥银行数据 | 墨西哥银行负责货币政策和本国货币(比索),并提供账户和所有宏观经济变量的数据。 | -| BATS | BATS美国证券交易所数据 | Bats是美国的股票市场运营商,经营四个股票交易所--BZX Exchange,BYX Exchange,EDGA Exchange和EDGX Exchange | -| BSE | 孟买证券交易所数据 | 在印度孟买证券交易所交易的公司的日终价格,指数和其他信息。 | -| FRED | 美联储经济数据 | 来自圣路易斯联邦储备银行研究部门的增长,就业,通货膨胀,劳工,制造业和其他美国经济统计数据。 | -| FMAC | 房地美数据 | Freddie Mac的主要抵押贷款市场调查和其他地区特定历史抵押贷款利率的数据。 | -| EUREX | 欧洲期货交易所数据 | 欧洲最大的期货交易所EUREX的指数,利率,农业和能源期货,历史跨越了特定期货的十年。 | -| ECB | 欧洲中央银行数据 | 欧盟中央银行监督货币政策和欧元,并提供相关宏观经济变量的数据。 | -| BOF | 法国银行数据 | 法兰西银行通过欧洲中央银行体系的政策负责货币政策,并提供关键经济指标的数据。 | -| BELGRADESE | 贝尔格莱德证券交易所数据 | 贝尔格莱德证券交易所数据,每日更新。 | -| CHRIS | 维基连续期货 | Quandl所有600个期货的连续合约。建立在CME,ICE,LIFFE等原始数据之上。由Quandl社区策划。 50年的历史。 | -| BOJ | 日本银行数据 | nan | -| USTREASURY | 美国财政部数据 | 美国财政部确保国家的金融安全,管理国家债务,收取税收,发行货币,提供收益率数据。 | -| LBMA | 伦敦金银市场协会数据 | 伦敦黄金和白银市场的国际贸易协会,由中央银行,私人投资者,生产商,炼油商和其他代理商组成。 | -| PERTH | 珀斯铸币厂数据 | 珀斯造币厂的利率和商品价格的高点,低点和平均值每月更新一次。 | -| ZILLOW2 | Zillow房地产研究 | 房屋价格和租金按大小,类型和等级划分;住房供应,需求和销售。按邮政编码,街区,城市,都市区,县和州切片。 | \ No newline at end of file + - Limit Number is the maximum number of data exported at a time. The default is 10000, and the maximum value can be filled in 100000. + - Offset Number is derived from the first few columns of the database, because the number of bars is limited. For example, we exported 10000 data before, but the obvious data has not been exported yet. We can use this function to select offset 10000 to start from the 10000th. Export (Note: the database count starts from 0, so the first 10000 is 0-9999) + +## Attachment + +| Database | Name | description | +| ------------ | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| PIKETTY | Thomas Piketty | Data on Income and Wealth from "Capital in the 21st Century", Harvard University Press 2014. | +| BUNDESBANK | Deutsche Bundesbank Data Repository | Data on the German economy, money and capital markets, public finances, banking, households, Euro-area aggregates, trade and external debt. | +| URC | Unicorn Research Corporation | Advance and decline data for the NYSE, AMEX, and NASDAQ stock exchanges. From various publicly-available sources and the median value is reported. | +| DCE | Dalian Commodities Exchange | Agriculture and commodities futures from DCE, with history spanning almost a decade for select futures. | +| WFC | Wells Fargo Home Mortgage Loans | This database offers mortgage purchase and refinance rates from Wells Fargo Home Mortgage, a division of Wells Fargo Bank. | +| USDAFNS | U.S. Department of Agriculture FNS | Food and Nutrition Service administrates federal nutrition assistance programs for low-income households and children. Data on costs and participation rates. | +| LJUBSE | Ljubljana Stock Exchange (Slovenia) | This database contains the Ljubljana Stock Exchange indexes and is based in Ljubljana, Slovenia. | +| TOCOM | Tokyo Commodities Exchange | Agriculture and commodities futures from Tokyo Commodities Exchange (TOCOM), with history spanning almost a decade for select futures. | +| WCSC | World Bank Corporate Scorecard | This database is designed to provide a strategic overview of the World Bank Group’s performance toward ending extreme poverty and promoting shared prosperity. | +| CMHC | Canadian Mortgage and Housing Corporation | The CMHC is a gov’t-owned corporation that provides affordable housing to Canadian citizens and collects data such as prices, construction, and supply. | +| WGEC | World Bank Global Economic Monitor (GEM) Commodities | Data containing commodity prices and indices from 1960 to present. | +| FED | US Federal Reserve Data Releases | Official US figures on money supply, interest rates, mortgages, government finances, bank assets and debt, exchange rates, industrial production. | +| WPSD | World Bank Public Sector Debt | Data jointly developed by the World Bank and the International Monetary Fund, which brings together detailed public sector government debt data. | +| UGID | United Nations Global Indicators | This database offers a wide range of global indicators, covering population, public health, employment, trade, education, inflation and external debt. | +| RBA | Reserve Bank of Australia | Central bank and monetary authority, regulates banking industry, sets interest rates, and services governments debt. Data on key economic indicators. | +| UCOM | United Nations Commodity Trade | This database offers comprehensive global data on imports and exports of commodities such as food, live animals, pharmaceuticals, metals, fuels and machinery. | +| SIDC | Solar Influences Data Analysis Center | The SIDC hosts data spanning from the 1700s on solar activity, specifically sunspot activity. | +| ZCE | Zhengzhou Commodities Exchange | Agriculture and commodities futures from ZCE, with history spanning almost a decade for select futures. | +| USDAFAS | U.S. Department of Agriculture FAS | The USDA Foreign Agricultural Service connects U.S. agriculture with the world markets. It provides statistics on production and exports in foreign countries. | +| OECD | Organisation for Economic Co-operation and Development | International organization of developed countries that promotes economic welfare. Collects data from members and others to make policy recommendations. | +| OPEC | Organization of the Petroleum Exporting Countries | International organization and economic cartel overseeing policies of oil-producers, such as Iraq, Iran, Saudi Arabia, and Venezuela. Data on oil prices. | +| MCX | Multi Commodity Exchange India | Indias largest commodity exchange servicing futures trading in metals, energy, and agriculture. Worlds 3rd largest exchange in contracts and trading volume. | +| ECONOMIST | The Economist - Big Mac Index | The Big Mac index was invented by The Economist in 1986 as a lighthearted guide to whether currencies are at their “correct” level. It is based on the theory of purchasing-power parity (PPP). | +| NSDL | National Securities Depository Limited (India) | Depository in India responsible for economic development of the country that has established a national infrastructure of international standards that handles most of the securities held and settled in dematerialised form in the Indian capital market. | +| GDT | Global Dairy Trade | nan | +| CFFEX | China Financial Futures Exchange | Index and bond futures from CFFEX, with history spanning almost a decade for select futures. | +| CITYPOP | Thomas Brinkhoff: City Populations | Thomas Brinkhoff provides population data for cities and administrative areas in most countries. | +| BCHARTS | Bitcoin Charts Exchange Rate Data | Exchange rates for bitcoin against a large number of currencies, from all major bitcoin exchanges, including current and historical exchange rates. | +| LOCALBTC | Local Bitcoins | nan | +| JODI | JODI Oil World Database | JODI oil and gas data comes from over 100 countries consisting of multiple energy products and flows in various methods of measurement. | +| UENG | United Nations Energy Statistics | This database offers comprehensive global statistics on production, trade, conversion, and final consumption of new and renewable energy sources. | +| ULMI | United Nations Labour Market Indicators | This database offers comprehensive youth unemployment figures broken up by gender for all countries in the world. | +| MAURITIUSSE | Stock Exchange of Mauritius | Stock Exchange of Mauritius indices data. | +| UKRSE | Ukrainian Exchange | UKRSE presents the most current available data related to the largest stock exchanges in Ukraine. The exchange is located in Kiev and accounts for roughly three-quarters of Ukraines total equity trading volume | +| BITSTAMP | Bitstamp | Bitstamp is a trading platform for Bitcoin. | +| UNAE | United Nations National Accounts Estimates | This database offers global data on gross domestic product, gross national income, and gross value added by different sectors for all countries in the world. | +| UNAC | United Nations National Accounts Official Country Data | This database offers global data on national accounts, such as assets and liabilities of households, corporations and governments. | +| UTOR | United Nations World Tourism | This database offers comprehensive data on international tourism. Data includes number of tourist arrivals and tourism expenditures for all countries. | +| WFE | World Federation of Exchanges | A trade association of sixty publicly regulated stock, futures, and options exchanges that publishes data for its exchanges, like market capitalization. | +| FRBC | Federal Reserve Bank of Cleveland | The Federal Reserve Bank of Cleveland collects data from hundreds of financial institutions, including depository institutions, bank holding companies, and other entities that is used to assess financial institution conditions and also to glean insights into how the economy and financial system are doing. | +| UGEN | United Nations Gender Information | This database offers comprehensive global data on a wide range of gender-related indicators, covering demography, health, education and employment. | +| BITFINEX | Bitfinex | Bitfinex is a trading platform for Bitcoin, Litecoin and Darkcoin with many advanced features including margin trading, exchange and peer to peer margin funding. | +| UGHG | United Nations Greenhouse Gas Inventory | This database offers comprehensive global data on anthropogenic emissions of the six principal greenhouse gases. Data goes back to 1990. | +| UIST | United Nations Industrial Development Organization | This database offers global data on industrial development indicators, including output, employees, wages, value added for a wide range of industries. | +| PRAGUESE | Prague Stock Exchange | Price index data from the Prague Stock Exchange. | +| PFTS | PFTS Stock Exchange (Ukraine) | Index data from the PFTS Stock Exchange, the largest marketplace in Ukraine. | +| WARSAWSE | Warsaw Stock Exchange | WIG20 index has been calculated since April 16, 1994 based on the value of portfolio with shares in 20 major and most liquid companies in the WSE Main List. | +| TUNISSE | Tunis Stock Exchange | The main reference index of Tunis Stock Exchange. | +| FRKC | Federal Reserve Bank of Kansas City | FRKC is the regional central bank for the 10th District of the Federal Reserve, publishing data on banking in mostly agricultural transactions. | +| UENV | United Nations Environment Statistics | This database offers global data on water and waste related indicators, including fresh water supply and precipitation, and generation and collection of waste. | +| UFAO | United Nations Food and Agriculture | This database offers global food and agricultural data, covering crop production, fertilizer consumption, use of land for agriculture, and livestock. | +| TAIFEX | Taiwan Futures Exchange | Index and bond futures from TAIFEX, with history spanning over a decade for select futures. | +| GDAX | GDAX (Global Digital Asset Exchange) | GDAX is the world’s most popular place to buy and sell bitcoin. | +| ARES | Association for Real Estate Securitization | ARES protects investors, contributes to development of the real estate securitization product market, and facilitates expansion of the real estate investment market. | +| SHADOWS | Wu-Xia Shadow Federal Funds Rate | This dataset contains the three major indicators from the Wu-Xia papers which serve to identify the shadow rates on all three major banks. | +| NAAIM | NAAIM Exposure Index | The NAAIM Exposure Index represents the average exposure to US Equity markets reported by NAAIM members. | +| CBRT | Central Bank of the Republic of Turkey | CBRT is responsible for taking measures to sustain the stability of the financial system in Turkey. | +| CEGH | Central European Gas Hub | No description for this database yet. | +| FINRA | Financial Industry Regulatory Authority | Financial Industry Regulatory Authority provides short interest data on securities firms and exchange markets. | +| NASDAQOMX | NASDAQ OMX Global Index Data | Over 35,000 global indexes published by NASDAQ OMX including Global Equity, Fixed Income, Dividend, Green, Nordic, Sharia and more. Daily data. | +| EURONEXT | Euronext Stock Exchange | Historical stock data from Euronext, the largest European exchange. | +| UICT | United Nations Information and Communication Technology | This database offers comprehensive global data on information and communication technology, including telephone, cellular and internet usage for all countries. | +| USAID | U.S. Agency for International Development | US Agency for International Development provides a complete historical record of all foreign assistance provided by the United States to the rest of the world. | +| ZAGREBSE | Zagreb Stock Exchange | Croatias only stock exchange. It publishes data on the performance of its stock and bond indexes. | +| QUITOSE | Quito Stock Exchange (Ecuador) | The indexes of the national Stock Exchange of Ecuador. | +| ECBCS | European Commission Business and Consumer Surveys | Data in this database is derived from harmonized surveys for different sectors of the economies in the European Union (EU) and in the EU applicant countries. | +| PSE | Paris School of Economics | This database describes the distribution of top incomes in a growing number of countries. Numbers are derived using tax data. | +| MALTASE | Malta Stock Exchange | The Malta Stock Exchange carries out the role of providing a structure for admission of financial instruments to its recognised lists which may subsequently be traded on a regulated, transparent and orderly market place (secondary market).The main participants in the market are Issuers, Stock Exchange Members (stockbrokers), and the investors in general. | +| GPP | Global Petroleum Prices | No description for this database yet. | +| PPE | Polish Power Exchange (TGE) | No description for this database yet. | +| UKONS | United Kingdom Office of National Statistics | Data on employment, investment, housing, household expenditure, national accounts, and many other socioeconomic indicators in the United Kingdom. | +| NCDEX | National Commodity & Derivatives Exchange Limited (India) | A professionally managed on-line multi-commodity exchange in India | +| WSE | Warsaw Stock Exchange (GPW) | No description for this database yet. | +| TFX | Tokyo Financial Exchange | The Tokyo Financial Exchange is a futures exchange that primary deals in financial instruments markets that handle securities and market derivatives. | +| WGFD | World Bank Global Financial Development | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | +| CEPEA | Center for Applied Studies on Applied Economics (Brazil) | CEPEA is an economic research center at the University of Sao Paulo focusing on agribusiness issues, publishing price indices for commodities in Brazil. | +| SBJ | Statistics Bureau of Japan | A Japanese government statistical agency that provides statistics related to employment and the labour force. | +| WGEM | World Bank Global Economic Monitor | Data on global economic developments, with coverage of high-income, as well as developing countries. | +| WGDF | World Bank Global Development Finance | Data on financial system characteristics, including measures of size, use, access to, efficiency, and stability of financial institutions and markets. | +| WWDI | World Bank World Development Indicators | Most current and accurate development indicators, compiled from officially-recognized international sources. | +| WESV | World Bank Enterprise Surveys | Company-level private sector data, covering business topics including finance, corruption, infrastructure, crime, competition, and performance measures. | +| WDBU | World Bank Doing Business | Data on business regulations and their enforcement for member countries and selected cities at the subnational and regional level. | +| OSE | Osaka Securities Exchange | The second largest securities exchange in Japan. Unlike the TSE, OSE is strongest in derivatives trading, the majority of futures and options in Japan. | +| RFSS | Russian Federation Statistics Service | The Russian governmental statistical agency that publishes social, economic, and demographic statistics for Russia at the national and local levels. | +| SHFE | Shanghai Futures Exchange | Commodities exchange for energy, metal, and chemical-related industrial products. A derivatives marketplace for many commodities futures. | +| WGEP | World Bank GEP Economic Prospects | Data on the short-, medium, and long-term outlook for the global economy and the implications for developing countries and poverty reduction. | +| USMISERY | United States Misery Index | Developed by economist Arthur Okun, the Misery Index is the unemployment rate added to the inflation rate. | +| WJKP | World Bank Jobs for Knowledge Platform | Indicators on labor-related topics. | +| WMDG | World Bank Millennium Development Goals | Data drawn from the World Development Indicators, reorganized according to the goals and targets of the Millennium Development Goals (MDGs). | +| WPOV | World Bank Poverty Statistics | Indicators on poverty headcount ratio, poverty gap, and number of poor at both international and national poverty lines. | +| EUREKA | Eurekahedge | A research company focused on hedge funds and other alternative investment funds. It publishes data on the performances of hedge funds. | +| MOFJ | Ministry of Finance Japan | Japanese government bond interest rate data, published daily by the Ministry of Finance. | +| PSX | Pakistan Stock Exchange | Daily closing stock prices from the Pakistan Stock Exchange. | +| SGX | Singapore Exchange | Asian securities and derivatives exchange that trades in equities for many large Singaporean and other Asian companies. Listed on its own exchange. | +| UIFS | United Nations International Financial Statistics | This database offers comprehensive data on international financial indicators, such as average earnings, bond yields, government revenues and expenditures. | +| UINC | United Nations Industrial Commodities | This database offers global data on production of industrial commodities, such as ores and minerals, food products, transportable goods, and metal products. | +| INSEE | National Institute of Statistics and Economic Studies (France) | INSEE is the national statistical agency of France. It collects data on Frances economy and society, such as socioeconomic indicators and national accounts. | +| SNB | Swiss National Bank | Central bank responsible for monetary policy and currency. Data on international accounts, interest rates, money supply, and other macroeconomic indicators. | +| ODE | Osaka Dojima Commodity Exchange | A non-profit commodity exchange in the Kansai region of Japan that trades in seven key agricultural commodities. | +| WGEN | World Bank Gender Statistics | Data describing gender differences in earnings, types of jobs, sectors of work, farmer productivity, and entrepreneurs’ firm sizes and profits. | +| WHNP | World Bank Health Nutrition and Population Statistics | Key health, nutrition and population statistics. | +| WIDA | World Bank International Development Association | Data on progress on aggregate outcomes for IDA (International Development Association) countries for selected indicators. | +| ECMCI | European Commission Monetary Conditions Index | Updated monthly, this database provides monetary conditions index values in the Euro zone. History goes back to 1999. | +| NBSC | National Bureau of Statistics of China | Statistics of China relating to finance, industry, trade, agriculture, real estate, and transportation. | +| MAS | Monetary Authority of Singapore | No description for this database yet. | +| MGEX | Minneapolis Grain Exchange | A marketplace of futures and options contracts for regional commodities that facilitates trade of agricultural indexes. | +| WWGI | World Bank Worldwide Governance Indicators | Data on aggregate and individual governance indicators for six dimensions of governance. | +| ISM | Institute for Supply Management | ISM promotes supply-chain management practices and publishes data on production and supply chains, new orders, inventories, and capital expenditures. | +| UKR | Ukrainian Exchange | No description for this database yet. | +| FRBNY | Federal Reserve Bank of New York | The FRBNY is the largest regional central bank in the US. Sets monetary policy for New York, most of Connecticut and New Jersey, and some territories. | +| FRBP | Federal Reserve Bank of Philadelphia | The FRBP is a regional central bank for the Federal Reserve. It publishes data on business confidence indexes, GDP, consumption, and other economic indicators. | +| FMSTREAS | US Treasury - Financial Management Service | The monthly receipts/outlays and deficit/surplus of the United States of America. | +| EIA | U.S. Energy Information Administration Data | US national and state data on production, consumption and other indicators on all major energy products, such as electricity, coal, natural gas and petroleum. | +| SOCSEC | Social Security Administration | Provides data on the US social security program, particularly demographics of beneficiaries; disabled, elderly, and survivors. | +| TFGRAIN | Top Flight Grain Co-operative | Cash price of corn and soybeans including basis to front month futures contract. | +| IRPR | Puerto Rico Institute of Statistics | Puerto Rico Institute of Statistics statistics on manufacturing. | +| BCHAIN | Blockchain | Blockchain is a website that publishes data related to Bitcoin, updated daily. | +| BITCOINWATCH | Bitcoin Watch | Bitcoin mining statistics. | +| ODA | IMF Cross Country Macroeconomic Statistics | IMF primary commodity prices and world economic outlook data, published by Open Data for Africa. Excellent cross-country macroeconomic data. | +| WADI | World Bank Africa Development Indicators | A collection of development indicators on Africa, including national, regional and global estimates. | +| WEDU | World Bank Education Statistics | Internationally comparable indicators on education access, progression, completion, literacy, teachers, population, and expenditures. | +| WGLF | World Bank Global Findex (Global Financial Inclusion database) | Indicators of financial inclusion measures on how people save, borrow, make payments and manage risk. | +| WWID | World Wealth and Income Database | The World Wealth and Income Database aims to provide open and convenient access to the most extensive available database on the historical evolution of the world distribution of income and wealth, both within countries and between countries. | +| BTER | BTER | Historical exchange rate data for crypto currencies. | +| CFTC | Commodity Futures Trading Commission Reports | Weekly Commitment of Traders and Concentration Ratios. Reports for futures positions, as well as futures plus options positions. New and legacy formats. | +| BOE | Bank of England Official Statistics | Current and historical exchange rates, interest rates on secured loans and time deposits, Euro-commercial paper rates, and yields on government securities. | +| EXMPL | Quandl Example Time-Series Data | An example time series database. | +| WORLDAL | Aluminium Prices | World Aluminium capacity and production in thousand metric tonnes. | +| WGC | Gold Prices | The World Gold Council is a market development organization for the gold industry. It publishes data on gold prices in different currencies. | +| MX | Canadian Futures | Montreal Exchange is a derivatives exchange that trades in futures contracts and options for equities, indices, currencies, ETFs, energy, and interest rates. | +| UMICH | Consumer Sentiment | The University of Michigan’s consumer survey - data points for the most recent 6 months are unofficial; they are sourced from articles in the Wall Street Journal. | +| JOHNMATT | Rare Metals | Current and historical data on platinum group metals such as prices, supply, and demand. | +| NAHB | US Housing Indices | Housing and economic indices for the United States. | +| RATEINF | Inflation Rates | Inflation Rates and the Consumer Price Index CPI for Argentina, Australia, Canada, Germany, Euro area, France, Italy, Japan, New Zealand and more. | +| RENCAP | IPOs | Data on the IPO market in the United States. | +| ML | Corporate Bond Yield Rates | Merrill Lynch, a major U.S. bank, publishes data on yield rates for corporate bonds in different regions. | +| MULTPL | S&P 500 Ratios | No description for this database yet. | +| RICI | Commodity Indices | Composite, USD based, total return index, representing the value of a basket of commodities consumed in the global economy. | +| AAII | Investor Sentiment | American Association of Individual Investor’s sentiment data. | +| BIS | Bank for International Settlements | BIS serves central banks with administration of monetary and financial stability, fosters international cooperation, and acts as bank for central banks. | +| BCB | Central Bank of Brazil Statistical Database | Brazilian macroeconomic data, covering public finances, national accounts, payment systems, inflation, exchange rates, trade, and international reserves. | +| BCRA | Central Bank of Argentina | The Central Bank of Argentina is responsible monetary policy and provides data on foreign exchange markets and key macroeconomic indicators. | +| FSE | Frankfurt Stock Exchange | Daily stock prices from the Frankfurt Stock Exchange | +| BLSN | BLS International | Import and export price statistics for various countries, published by the Bureau of Labor Statistics. | +| BLSP | BLS Productivity | US manufacturing, labor and business statistics, published by the Bureau of Labor Statistics. | +| FDIC | Federal Deposit Insurance Corporation | The FDIC is a federal insurer of bank deposits up to $250k and collects finance data on commercial banking and savings institutions. | +| BLSI | BLS Inflation & Prices | US national and state-level inflation data, published by the Bureau of Labor Statistics. | +| BLSE | BLS Employment & Unemployment | US national and state-level employment and unemployment statistics, published by the Bureau of Labor Statistics. | +| BLSB | BLS Pay & Benefits | US work stoppage statistics, published by the Bureau of Labor Statistics. | +| BP | Energy Production and Consumption | BP is a large energy producer and distributor. It provides data on energy production and consumption in individual countries and larger subregions. | +| LPPM | Platinum & Palladium Prices | Price data on the market-clearing level for Palladium and Platinum around the world. | +| CASS | Freight Indices | Since 1990, CASS provides monthly Cass Freight Index Reports on freight trends as they relate to other economic and supply chain indicators. | +| MORTGAGEX | ARM Indices | Historical housing data on ARM indexes. | +| BUCHARESTSE | Bucharest Stock Exchange | The Bucharest Stock Exchange publishes data on it activity in equity, rights, bonds, fund units, structured products, and futures contracts. | +| AMECO | European Commission Annual Macro-Economic Database | Annual macro-economic database of the European Commissions Directorate General for Economic and Financial Affairs (DG ECFIN). | +| ACC | American Chemistry Council | Chemical Activity Barometer (CAB) published by the American Chemistry Council (ACC). The CAB is an economic indicator that helps anticipate peaks and troughs in the overall US economy and highlights potential trends in other industries in the US. | +| ABMI | Asia Bond Market Initiative | Indicators of Chinese and Japanese bond markets, such as size and composition, market liquidity, yield returns, and volatility. | +| BITAL | Borsa Italiana | This database provides data on stock future contracts from the Borsa Italiana, now part of London Stock Exchange Group. | +| BANKRUSSIA | Bank of Russia | Primary indicators from the Bank of Russia, including data on the banking sector, money supply, financial markets and macroeconomic statistical data. | +| BOC | Bank of Canada Statistical Database | Economic, financial and banking data for Canada. Includes interest rates, inflation, national accounts and more. Daily updates. | +| HKEX | Hong Kong Exchange | Hong Kong Exchange stock prices, historical divided futures, etc. updated daily. | +| AMFI | Association of Mutual Funds in India | This database represents fund information from The Association of Mutual Funds in India. | +| BDM | Bank of Mexico | The Bank of Mexico is responsible for monetary policy and the national currency (peso), and provides data on accounts and all macroeconomic variables. | +| BATS | BATS U.S. Stock Exchanges | Bats is an equities market operator in the U.S., operating four equities exchanges — BZX Exchange, BYX Exchange, EDGA Exchange, and EDGX Exchange | +| BSE | Bombay Stock Exchange | End of day prices, indices, and additional information for companies trading on the Bombay Stock Exchange in India. | +| FRED | Federal Reserve Economic Data | Growth, employment, inflation, labor, manufacturing and other US economic statistics from the research department of the Federal Reserve Bank of St. Louis. | +| FMAC | Freddie Mac | Data from Freddie Mac’s Primary Mortgage Market Survey and other region specific historical mortgage rates. | +| EUREX | EUREX Futures Data | Index, rate, agriculture and energy futures from EUREX, Europes largest futures exchange, with history spanning a decade for select futures. | +| ECB | European Central Bank | The central bank for the European Union oversees monetary policy and the Euro, and provides data on related macroeconomic variables. | +| BOF | Bank of France | The Banque de France is responsible for monetary policy through policies of the European System of Central Banks and providing data on key economic indictors. | +| BELGRADESE | Belgrade Stock Exchange | Belgrade Stock Exchange data, updated daily. | +| CHRIS | Wiki Continuous Futures | Continuous contracts for all 600 futures on Quandl. Built on top of raw data from CME, ICE, LIFFE etc. Curated by the Quandl community. 50 years history. | +| BOJ | Bank of Japan | nan | +| USTREASURY | US Treasury | The U.S. Treasury ensures the nations financial security, manages the nations debt, collects tax revenues, and issues currency, provides data on yield rates. | +| LBMA | London Bullion Market Association | An international trade association in the London gold and silver market, consisting of central banks, private investors, producers, refiners, and other agents. | +| PERTH | Perth Mint | The Perth Mint’s highs, lows and averages of interest rates and commodities prices, updated on a monthly basis. | +| ZILLOW2 | Zillow Real Estate Research | Home prices and rents by size, type and tier; housing supply, demand and sales. Sliced by zip code, neighbourhood, city, metro area, county and state. | \ No newline at end of file From 91fb965eb73035a2fbd5d043858148f4c3d862c9 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Sun, 28 Apr 2019 16:34:55 +0800 Subject: [PATCH 338/421] New translations cql_db_manage.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/cql_db_manage.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md index d85f59e..76d7380 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md +++ b/website/translated_docs/zh-CN/version-0.5.0/cql_db_manage.md @@ -25,6 +25,24 @@ The sub-command `create` sends transactions to block producers to create databas For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). +## Billing + +CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `gas-price`. If not specified in the json string, it will be set as 1 by default. Another billing-related field is `advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`: + +```bash +cql create '{"node": 2, "gas-price": 5, "advance-payment": 500000000}' +``` + +Thus we created a new database with `Gas-Price` 5 and `Advance-Payment` 500,000,000. Note that when the CovenantSQL network is short of miner resources, setting a higher `Gas-Price` will help your creation request to be accepted earlier, but it will cost you more tokens of course. + +> At present, we only accept the CovenantSQL stable token Particle for database billing. More token types will be supported soon. + +And the billing is processed as following: + +- For a Read request, the result `rows_count` is counted as the `Gas` cost +- For a Write request, the result `affected_rows` is counted as the `Gas` cost +- The SQLChain miner does periodic billing, sums up, and reports the `Gas` cost to the main chain, and the main chain verifies and deducts `Gas` * `Gas Price` tokens from the user accounts + ## ~~Deleting Database~~ ~~Not yet implemented.~~ @@ -151,6 +169,8 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio eventual-consistency bool // Use eventual consistency to sync among miner nodes consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency isolation-level int // Isolation level in a single node + gas-price int // Specified Gas Price of the database, default is 1 Particle + advance-payment int // Specified advance payment of the database, default is 20,000,000 Particles Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. e.g. From 49d0d972a3fdd90f51b2b710f1bf84996b4870f7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Sun, 28 Apr 2019 16:35:12 +0800 Subject: [PATCH 339/421] New translations cql_db_manage.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_manage.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index 8a0b220..1e126cd 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -24,6 +24,24 @@ The sub-command `create` sends transactions to block producers to create databas For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). +## Billing + +CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `gas-price`. If not specified in the json string, it will be set as 1 by default. Another billing-related field is `advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`: + +```bash +cql create '{"node": 2, "gas-price": 5, "advance-payment": 500000000}' +``` + +Thus we created a new database with `Gas-Price` 5 and `Advance-Payment` 500,000,000. Note that when the CovenantSQL network is short of miner resources, setting a higher `Gas-Price` will help your creation request to be accepted earlier, but it will cost you more tokens of course. + +> At present, we only accept the CovenantSQL stable token Particle for database billing. More token types will be supported soon. + +And the billing is processed as following: + +- For a Read request, the result `rows_count` is counted as the `Gas` cost +- For a Write request, the result `affected_rows` is counted as the `Gas` cost +- The SQLChain miner does periodic billing, sums up, and reports the `Gas` cost to the main chain, and the main chain verifies and deducts `Gas` * `Gas Price` tokens from the user accounts + ## ~~Deleting Database~~ ~~Not yet implemented.~~ @@ -150,6 +168,8 @@ Either setting the `pattern` field to `nil` or just resetting the user permissio eventual-consistency bool // Use eventual consistency to sync among miner nodes consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency isolation-level int // Isolation level in a single node + gas-price int // Specified Gas Price of the database, default is 1 Particle + advance-payment int // Specified advance payment of the database, default is 20,000,000 Particles Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. e.g. From d76ca415e16329e8003909663addb586be0924fd Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 14 May 2019 16:06:25 +0800 Subject: [PATCH 340/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 10ef58a..f53129f 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -82,7 +82,7 @@ chmod 600 ~/.cql/testnet-conf/private.key ## Create a database ```bash -cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ +cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ -wait-tx-confirm '{"node":1}' ``` @@ -105,7 +105,7 @@ This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69 ## Access the database ```bash -cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ +cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` From 4763991ef65ec806e22cd79012ab1916968bcc21 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 14 May 2019 16:06:26 +0800 Subject: [PATCH 341/421] New translations adpater.md (Chinese Simplified) --- website/translated_docs/zh-CN/adpater.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/adpater.md b/website/translated_docs/zh-CN/adpater.md index a0f8e81..18bb37e 100644 --- a/website/translated_docs/zh-CN/adpater.md +++ b/website/translated_docs/zh-CN/adpater.md @@ -24,7 +24,7 @@ docker run -itd \ --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ -v ~/.cql/config.yaml:/app/config.yaml \ -v ~/.cql/private.key:/app/private.key \ - --name cql-adapter -p $adapter_addr:4661 \ + --name cql-adapter -p $adapter_addr:4661 \ covenantsql/covenantsql:testnet 0.0.0.0:4661 ``` From 953918fb387a58c63433fc2b45e289bdae1f7a85 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 14 May 2019 16:59:47 +0800 Subject: [PATCH 342/421] New translations adpater.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/adpater.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/adpater.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/adpater.md b/website/translated_docs/zh-CN/version-0.6.0/adpater.md new file mode 100644 index 0000000..adfb54d --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/adpater.md @@ -0,0 +1,59 @@ +--- +id: version-0.6.0-adapter +title: Adapter +original_id: adapter +--- + +# Use Adapter to access CovenantSQL + +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. + +## How to use + +First, [Install docker](https://docs.docker.com/install/). + +Secondly, before using CovenantSQL, a proper configuration file and an asymmetric key-pair is required. If no configuration file is specified, CovenantSQL tries to load configuration from `~/.cql/config.yaml`. For configuration file and key-pair generation, please refer to [QuickStart#CreateAccount](./quickstart#CreateAccount) + +### Start adapter using docker + +Following command will use config file `~/.cql/config.yaml` and key-pair `~/.cql/private.key` to start adapter service and serving at `0.0.0.0:11105`. + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet 0.0.0.0:4661 +``` + +### Create database + +Create new database using `cql create` command and provide database instance requirements. + +For example, create a single node database instance: + +```bash +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + create -config /app/config.yaml -wait-tx-confirm '{"node": 1}' +``` + +This command would produce a database connection string (DSN) similar to following example. + +```bash +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +Use DSN to access CovenantSQL using various drivers. + +## Drivers + +1. [Golang](./driver_golang) +2. [Java](./driver_java) +3. [Python](./driver_python) +4. [NodeJS](./driver_js) \ No newline at end of file From 53e282c3dcbb7dfe2be08467d104dee736ce8845 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 14 May 2019 16:59:48 +0800 Subject: [PATCH 343/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/quickstart.md | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/quickstart.md b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md new file mode 100644 index 0000000..88c467c --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md @@ -0,0 +1,186 @@ +--- +id: version-0.6.0-quickstart +title: Quick Start +original_id: quickstart +--- + + +## CovenantSQL Client + +### Install + +Please choose the installation method according to the operating system platform you use: + +#### MacOS + +- 🍺 Homebrew users can just run: + +```bash + brew install cql + ``` + +- non-Homebrew users can run: + + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` + +#### Linux + +- Just run: + + ```bash + sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` + +After the installation is complete, you can execute the following command to check whether the installation is successful. + +```bash +cql version +``` + +If you have any errors on the MacOS or Linux, you can try the following to fix it: + +```bash +sudo chmod a+x /usr/local/bin/cql* # Fix Permission +sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH +``` + +If the problem persists please check out our GitHub page [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D) + +### Utils + +| Tool | Introduction | +| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` The command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | + +> Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) + +### TestNet + +At present, we have released the test network v0.5.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". + +The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: + +```bash +mkdir -p ~/.cql/testnet-conf +curl -L https://git.io/fhFZe --output ~/.cql/testnet-conf/config.yaml +curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key +chmod 600 ~/.cql/testnet-conf/private.key +``` + +**TestNet Notes**: + +> The "public account" is public and only for testing. Please do not store your application information in the database created by the "public account". We will clean the database data from time to time. +> +> The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. + +## Create a database + +```bash +cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ +-wait-tx-confirm '{"node":1}' +``` + +The command execution takes a little long time, and the console outputs after about 30 seconds: + +> covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + +​ + +This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. + +> Command execution takes some time, and the general process is: +> +> 1. The "Block Producer" that received the request performs a match of Miner and database creation requests. +> 2. Database creation request is verified and confirmed at other "Block Producer" nodes +> 3. Eligible Miner on SQLChain receives database task +> 4. SQLChain Miners builds a database cluster with Kayak +> 5. All Miners are ready to wait for a database request + +## Access the database + +```bash +cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ +-dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. + +## SQLChain Explorer + +One feature of CovenantSQL is that its query records are **immutable and traceable**, you can query the operation of a database through \[Test Web Block Browser\] (https://explorer.dbhub.org/) recording. + +> The TestNet's SQLChain Explorer is currently open-access, and anyone who knows the database ID can manipulate your data using TestNet's public key. + +Please fill in your database ID in the upper right corner of the page. For example: `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872`. You can see information about all the data created using TestNet's Key: + +![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) + +> **If you want to create your own private database, you need to create a new public-private key pair from scratch, please refer to the following section.** + +## Create your own account + +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): + +```bash +cql generate -no-password config +``` + +Output: + + INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 + "/home/work/.cql" already exists. + Do you want to delete it? (y or n, press Enter for default n): + y + Generating key pair... + Private key file: /home/work/.cql/private.key + Public key's hex: 024123d10696cf54fbf2b1e2b507ec4d1cbf2b4e87095774ad5fd6376cdae88e87 + Generated key pair. + Generating nonce... + INFO[0001] cpu: 2 + INFO[0001] position: 2, shift: 0x0, i: 1 + INFO[0001] position: 0, shift: 0x0, i: 0 + nonce: {{2556203225 0 0 0} 24 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad} + node id: 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad + Generated nonce. + Generating config file... + Generated config. + + +This command will create a `.cql` directory for you in your `$HOME` directory: + +- `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; +- `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. + +Let's continue to generate the account address (also called the wallet address, CovenantSQL address): + +```bash +cql wallet -no-password +``` + +Output: + + wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c + + +You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). + +After up to 2 minutes, you can use the cql command line tool to check the balance: + +```bash +cql wallet -no-password -balance all +``` + +output: + + Particle balance is: 10000000 + Wave balance is: 0 + + +Congratulations, you have received our PTC stable currency, and you can start using CovenantSQL now. You can refer to [Golang uses CovenantSQL documentation](./driver_golang) for development. \ No newline at end of file From 1a6cd86ddeeca7adbf2066aee31b02ab59209902 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 08:16:11 +0800 Subject: [PATCH 344/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 78 ++++++++++----------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index f53129f..f02f376 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -51,12 +51,12 @@ If the problem persists please check out our GitHub page [submit issue](https:// ### Utils -| Tool | Introduction | -| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -| cql | CovenantSQL client, `cql console` The command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | -| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | -| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | -| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | +| Tool | Introduction | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | > Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) @@ -79,20 +79,20 @@ chmod 600 ~/.cql/testnet-conf/private.key > > The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. -## Create a database +## Create a testnet database ```bash -cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ --wait-tx-confirm '{"node":1}' +cql create -config=~/.cql/testnet-conf/config.yaml \ + -db-node 1 -wait-tx-confirm ``` -The command execution takes a little long time, and the console outputs after about 30 seconds: +The command execution takes a little long time, and after about 30 seconds the console outputs something like below: > covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ​ -This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. +This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. > Command execution takes some time, and the general process is: > @@ -102,11 +102,11 @@ This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69 > 4. SQLChain Miners builds a database cluster with Kayak > 5. All Miners are ready to wait for a database request -## Access the database +## Access the testnet database ```bash -cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ --dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +cql console -config=~/.cql/testnet-conf/config.yaml \ + -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. @@ -128,52 +128,50 @@ Please fill in your database ID in the upper right corner of the page. For examp Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): ```bash -cql generate -no-password config +cql generate ``` Output: - INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 - "/home/work/.cql" already exists. - Do you want to delete it? (y or n, press Enter for default n): - y - Generating key pair... - Private key file: /home/work/.cql/private.key - Public key's hex: 024123d10696cf54fbf2b1e2b507ec4d1cbf2b4e87095774ad5fd6376cdae88e87 - Generated key pair. + Generating private key... + Please enter password for new private key + Generated private key. Generating nonce... - INFO[0001] cpu: 2 - INFO[0001] position: 2, shift: 0x0, i: 1 - INFO[0001] position: 0, shift: 0x0, i: 0 - nonce: {{2556203225 0 0 0} 24 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad} - node id: 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b Generated nonce. Generating config file... Generated config. + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + This command will create a `.cql` directory for you in your `$HOME` directory: - `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; - `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. -Let's continue to generate the account address (also called the wallet address, CovenantSQL address): - -```bash -cql wallet -no-password -``` - -Output: - - wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c - +It alse print your wallet address(also called the account address, CovenantSQL address): `Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95` You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). -After up to 2 minutes, you can use the cql command line tool to check the balance: +After up to 2 minutes while requested PTC, you can use the cql command line tool to check the balance: ```bash -cql wallet -no-password -balance all +cql wallet ``` output: From 1911a39b25dda0e48184b5f4d5167cc83e8ff0d0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 08:16:17 +0800 Subject: [PATCH 345/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 82 +++++++++++++------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md index dfe35d3..09fb550 100644 --- a/website/translated_docs/zh-CN/cql_account.md +++ b/website/translated_docs/zh-CN/cql_account.md @@ -10,7 +10,7 @@ For the TestNet environment, we provide a public account for quick testing. Chec The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: ```bash -cql generate config +cql generate ``` > Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. @@ -19,56 +19,80 @@ For a complete help message, check [Complete Parameters](#sub-command-generate-c Output: - Generating key pair... - Enter master key(press Enter for default: ""): - - Private key file: ~/.cql/private.key - Public key's hex: 027af3584b8b4736d6ba1e78ace5f0fdefe561f08749c5cac39d23668c3030fe39 - Generated key pair. + Generating private key... + Please enter password for new private key + Generated private key. Generating nonce... - INFO[0075] cpu: 4 - INFO[0075] position: 3, shift: 0x0, i: 3 - INFO[0075] position: 1, shift: 0x0, i: 1 - INFO[0075] position: 0, shift: 0x0, i: 0 - INFO[0075] position: 2, shift: 0x0, i: 2 - nonce: {{1056388 0 0 1424219234} 25 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01} - node id: 000000737633a77a39fc5e0a1855ca2c441486fef049ac4069e93dde6e58bb01 + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b Generated nonce. Generating config file... - Generated nonce. + Generated config. + + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 -## Acquiring the Public Key +### Public Key -The sub-command `generate` is also used to acquire the public key (in hex string format) of the private key file, e.g.: +Generate command also print public key (in hex string format) of the private key file, e.g.: -```bash -cql generate public -``` +Output: + + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + +> This info is usually not used in common scene. + +### Wallet address + +Generate command shows wallet address (in hex string format) and will store in `config.yaml` file, e.g.: Output: - Enter master key(press Enter for default: ""): + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 - INFO[0011] init config success path=/home/levente/.cql/private.key - INFO[0011] use public key in config file: /home/levente/.cql/config.yaml - Public key's hex: 02fd4089e7f4ca224f576d4baa573b3e9662153c952fce3f87f9586ffdd11baef6 + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 -> This functionality is usually not used in common scene. +After get a wallet address, you may need to request PTC as below. ## Sub-command `generate` Complete Parameters Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. - usage: cql generate [common params] config | public + usage: cql generate [common params] [-source template_file] [-miner] [-private existing_private_key] [dest_path] Generate generates private.key and config.yaml for CovenantSQL. + You can input a passphrase for local encrypt your private key file by set -with-password e.g. - cql generate config + cql generate - Params: - + or input a passphrase by + + cql generate -with-password + + Generate params: + -miner string + Generate miner config with specified miner address + -private string + Generate config using an existing private key + -source string + Generate config using the specified config template ## Mine a Node ID From ab9643cf542db99d9877a3ecbc491449298dd66e Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 08:16:19 +0800 Subject: [PATCH 346/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md index 9649402..c88cccd 100644 --- a/website/translated_docs/zh-CN/cql_intro.md +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -18,14 +18,14 @@ For security, the private key file is usually encrypted with a master key. A mas The following parameters are commonly used by `cql` sub-commands: - -bypass-signature - Disable signature signing and verifying, for testing only -config string Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") - -no-password - Use an empty master key + -with-password + Use passphrase for private.key -password string Master key for covenantsql (NOT SAFE, for debugging or script mode only) + -help + Show help message Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. \ No newline at end of file From 3f1e8a18ecdac5d3204dc7b4324d8e62f67115da Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 08:16:21 +0800 Subject: [PATCH 347/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 100 ++++++++++++-------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index f25fd5e..58f17a9 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -13,16 +13,22 @@ cql wallet Output: - Enter master key(press Enter for default: ""): + INFO[0000] Geting bp address from dns: bp00.testnet.gridb.io + INFO[0003] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 + INFO init config success path=~/.cql/config.yaml - wallet address: 43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 + + wallet address: 290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613 + Particle balance is: 100000000 + Wave balance is: 0 + found no related database -The wallet address of the test account here is `43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40`. +The wallet address of the test account here is `290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613`. And balances are also shown. ## Wallet Balances -We can also use sub-command `wallet` to check the balances in the wallet. CovenantSQL currently supports 5 types of tokens: +CovenantSQL currently supports 5 types of tokens: - `Particle` - `Wave` @@ -30,85 +36,95 @@ We can also use sub-command `wallet` to check the balances in the wallet. Covena - `Ether` - `EOS` -Among them, `Particle` and `Wave` are the token types used by CovenantSQL. To check the token balances, use: +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: ```bash -cql wallet -balance all +cql wallet -token Bitcoin ``` Output: - INFO[0000] Particle balance is: 10000000000000000000 - INFO[0000] Wave balance is: 10000000000000000000 + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0006] Register self to blockproducer: 0000000000293f7216362791b6b1c9772184d6976cb34310c42547735410186c + INFO init config success path=~/.cql/config.yaml - -You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: - -```bash -cql wallet -balance Bitcoin -``` - -Output: - - INFO[0000] Bitcoin balance is: 0 + wallet address: 290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613 + Bitcoin balance is: 0 ## Transferring Tokens to Another Account -Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes a `json` format meta info as its main parameter, e.g.: +Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: -```json -{ - "addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Receiver wallet address - "amount": "1000000 Particle" // Transfer amount with token type -} +```bash +cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -type Particle ``` -Note that the receiver wallet address could be a user account address or a database address -- we treat the database as a special kind of account. While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. +`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-type` is for token type -> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). +## Transferring Tokens to a database -Pass the parameter to `transfer`: +If you want to transfer token to a database address, replace `-to-user` to `-to-dsn`, and set a CovenantSQL dsn string. e.g. ```bash -cql transfer '{"addr": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6","amount": "1000000 Particle"}' +cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -type Particle ``` +While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. + +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). + Output: - INFO[0000] succeed in sending transaction to CovenantSQL + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0043] Register self to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in sending transaction to CovenantSQL -Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -balance ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -token ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. ## Sub-command `wallet` Complete Parameters - usage: cql wallet [common params] [-balance type] + usage: cql wallet [common params] [-token type] [-dsn dsn] Wallet gets the CovenantSQL wallet address and the token balances of the current account. e.g. cql wallet - cql wallet -balance Particle - cql wallet -balance all + cql wallet -token Particle + + cql wallet -dsn "covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c" - Params: - -balance string - Get a specific token's balance of the current account, e.g. Particle, Wave, and etc. + Wallet params: + -dsn string + Show specified database deposit + -token string + Get specific token's balance of current account, e.g. Particle, Wave, All ## Sub-command `transfer` Complete Parameters - usage: cql transfer [common params] [-wait-tx-confirm] meta_json + usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-type token_type] - Transfer transfers your token to the target account. The command argument is a token transaction in JSON format. + Transfer transfers your token to the target account or database. + The command arguments are target wallet address(or dsn), amount of token, and token type. e.g. - cql transfer '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' + cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle - Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the transfer takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the transfer takes effect. e.g. - cql transfer -wait-tx-confirm '{"addr": "43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40", "amount": "100 Particle"}' + cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle - Params: + Transfer params: + -amount uint + Token account to transfer. + -to-dsn string + Target database dsn to transfer token. + -to-user string + Target address of an user account to transfer token. + -type string + Token type to transfer. -wait-tx-confirm Wait for transaction confirmation \ No newline at end of file From 9bb99ce8ba546f2c9af5d9e7cda2b5238bb31990 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:34:39 +0800 Subject: [PATCH 348/421] New translations advanced_deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/advanced_deployment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/advanced_deployment.md b/website/translated_docs/zh-CN/advanced_deployment.md index b5137d9..a987a4b 100644 --- a/website/translated_docs/zh-CN/advanced_deployment.md +++ b/website/translated_docs/zh-CN/advanced_deployment.md @@ -85,14 +85,14 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 1 ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -no-password '{"node":1}' +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 2 ``` The command will return the connection string of the created database instance @@ -105,7 +105,7 @@ The command will return the connection string of the created database instance Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```bash -docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml -no-password -dsn covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode From d1f483019b2723b672470d72adf27d7a32d29846 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:35:01 +0800 Subject: [PATCH 349/421] New translations cql_db_manage.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_manage.md | 175 ++++++++++-------- 1 file changed, 102 insertions(+), 73 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index 1e126cd..3e5499a 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -5,20 +5,25 @@ title: Database Management ## Creating Database -Like `transfer`, `create` takes a `json` format main parameter. Create a database with one miner node with: +Like `transfer`, `create` takes several parameters. e.g. Create a database with one miner node: ```bash -cql create '{"node": 1}' +cql create -db-node 1 ``` Output: - Enter master key(press Enter for default: ""): + INFO[0000] Geting bp address from dns: bp00.testnet.gridb.io + INFO[0048] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 + INFO init config success path=~/.cql/config.yaml + INFO create database requested - covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + The newly created database is: "covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4" + The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console` + or any command, or be used in website like https://web.covenantsql.io -Here `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. +Here `covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. @@ -26,10 +31,10 @@ For a complete help message, check [Complete Parameters](#sub-command-create-com ## Billing -CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `gas-price`. If not specified in the json string, it will be set as 1 by default. Another billing-related field is `advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`: +CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `-db-gas-price`. If not specified in the parameter, it will be set as 1 by default. Another billing-related field is `-db-advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`: ```bash -cql create '{"node": 2, "gas-price": 5, "advance-payment": 500000000}' +cql create -db-node 2 -db-gas-price 5 -db-advance-payment 500000000 ``` Thus we created a new database with `Gas-Price` 5 and `Advance-Payment` 500,000,000. Note that when the CovenantSQL network is short of miner resources, setting a higher `Gas-Price` will help your creation request to be accepted earlier, but it will cost you more tokens of course. @@ -59,36 +64,44 @@ CovenantSQL database has 3 kinds of access permission: Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. -Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with the `json` format main parameter as following: +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with parameters as following: -```json -{ - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", // Target database adderss to give permission - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", // Target wallet address to get permission - "perm": "Read,Write" // Permission, separated by commas -} +```bash +`-to-dsn` Target database adderss to give permission +`-to-user` Target wallet address to get permission +`-perm` Permission, separated by commas ``` Pass the parameter to `grant`: ```bash -cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Read,Write"}' +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Read,Write" ``` Output: - INFO[0000] succeed in sending transaction to CovenantSQL + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in grant permission on target database Or revoke the permission: ```bash -cql grant '{"chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", "perm": "Void"}' +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Void" ``` Output: - INFO[0000] succeed in sending transaction to CovenantSQL + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in grant permission on target database The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. @@ -98,7 +111,10 @@ Since the database separately keeps billing for each user, you need to transfer Transferring from `account2` to the database: ```bash -cql -config "account2/config.yaml" transfer '{"addr": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5","amount": "90000000 Particle"}' +cql transfer -config "account2/config.yaml" \ + -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -amount 90000000 \ + -token Particle ``` ### SQL White List @@ -108,17 +124,15 @@ CovenantSQL supports white list setting for each of its users. By setting up SQL Adding a white list: ```bash -cql grant ' +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm ' { - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", - "perm": { - "patterns": [ - "SELECT COUNT(1) FROM a", - "SELECT * FROM a WHERE id = ? LIMIT 1" - ], - "role": "Read,Write" - } + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read,Write" } ' ``` @@ -128,87 +142,102 @@ cql grant ' Cleaning the white list: ```bash -cql grant ' +
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm ' { - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", - "perm": { - "patterns": nil, - "role": "Read,Write" - } + "patterns": nil, + "role": "Read,Write" } ' + or -cql grant ' -{ - "chain": "4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5", - "user": "011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6", - "perm": "Read,Write" -} -' + +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Read,Write" ``` Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. ## Sub-command `create` Complete Parameters - usage: cql create [common params] [-wait-tx-confirm] db_meta_json + usage: cql create [common params] [-wait-tx-confirm] [db_meta_params] - Create creates a CovenantSQL database by database meta info JSON string. The meta info must include node count. + Create command creates a CovenantSQL database by database meta params. The meta info must include + node count. e.g. - cql create '{"node": 2}' - - A complete introduction of db_meta_json fields: - target-miners []string // List of target miner addresses - node int // Target node number - space int // Minimum disk space requirement, 0 for none - memory int // Minimum memory requirement, 0 for none - load-avg-per-cpu float // Minimum idle CPU requirement, 0 for none - encrypt-key string // Encryption key for persistence data - eventual-consistency bool // Use eventual consistency to sync among miner nodes - consistency-level float // Consistency level, node*consistency_level is the node number to perform strong consistency - isolation-level int // Isolation level in a single node - gas-price int // Specified Gas Price of the database, default is 1 Particle - advance-payment int // Specified advance payment of the database, default is 20,000,000 Particles + cql create -db-node 2 - Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the creation takes effect. e.g. - cql create -wait-tx-confirm '{"node": 2}' - - Params: + cql create -wait-tx-confirm -db-node 2 + + DB meta params: + -db-advance-payment uint + Customized advance payment + -db-consistency-level float + Consistency level, node*consistency_level is the node count to perform strong consistency + -db-encrypt-key string + Encryption key for persistence data + -db-eventual-consistency + Use eventual consistency to sync among miner nodes + -db-gas-price uint + Customized gas price + -db-isolation-level int + Isolation level in a single node + -db-load-avg-per-cpu float + Minimum idle CPU requirement, 0 for none + -db-memory uint + Minimum memory requirement, 0 for none + -db-node uint + Target node count + -db-space uint + Minimum disk space requirement, 0 for none + -db-target-miners value + List of target miner addresses(separated by ',') -wait-tx-confirm Wait for transaction confirmation ## Sub-command `drop` Complete Parameters - usage: cql drop [common params] [-wait-tx-confirm] dsn/dbid + usage: cql drop [common params] [-wait-tx-confirm] dsn Drop drops a CovenantSQL database by DSN or database ID. e.g. cql drop covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c - Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the drop operation takes effect. e.g. cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c - Params: + Drop params: -wait-tx-confirm Wait for transaction confirmation ## Sub-command `grant` Complete Parameters - usage: cql grant [common params] [-wait-tx-confirm] permission_meta_json + usage: cql grant [common params] [-wait-tx-confirm] [-to-user wallet] [-to-dsn dsn] [-perm perm_struct] - Grant grants specific permissions for the target user. + Grant grants specific permissions for the target user on target dsn. e.g. - cql grant '{"chain": "your_chain_addr", "user": "user_addr", "perm": "perm_struct"}' + cql grant -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct - Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the permission takes effect. + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the permission takes effect. e.g. - cql grant -wait-tx-confirm '{"chain":"your_chain_addr","user":"user_addr","perm":"perm_struct"}' - - Params: + cql grant -wait-tx-confirm -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct + + Grant params: + -perm string + Permission type struct for grant. + -to-dsn string + Target database dsn to grant permission. + -to-user string + Target address of an user account to grant permission. -wait-tx-confirm Wait for transaction confirmation \ No newline at end of file From 96429abd06a7ced2043760e65cdbb42673b023e3 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:35:13 +0800 Subject: [PATCH 350/421] New translations cql_advance.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_advance.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_advance.md b/website/translated_docs/zh-CN/cql_advance.md index 210c8c0..2ee6744 100644 --- a/website/translated_docs/zh-CN/cql_advance.md +++ b/website/translated_docs/zh-CN/cql_advance.md @@ -7,7 +7,7 @@ Sub-command `rpc` calls the remote process directly in the CovenantSQL network. ## Sub-command `rpc` Complete Parameter - usage: cql rpc [common params] [-wait-tx-confirm] -name rpc_name -endpoint rpc_endpoint -req rpc_request + usage: cql rpc [common params] [-wait-tx-confirm] [-endpoint rpc_endpoint | -bp] -name rpc_name -req rpc_request RPC makes a RPC request to the target endpoint. e.g. @@ -15,12 +15,14 @@ Sub-command `rpc` calls the remote process directly in the CovenantSQL network. -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' - Params: + RPC params: + -bp + Call block producer node -endpoint string - RPC endpoint to do a test call + RPC endpoint Node ID to do test call -name string - RPC name to do a test call + RPC name to do test call -req string - RPC request to do a test call, in json format + RPC request to do test call, in json format -wait-tx-confirm Wait for transaction confirmation \ No newline at end of file From 30e4d10059ee8ecf6b9dca6793e91edafb88d0a8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:35:15 +0800 Subject: [PATCH 351/421] New translations cql_db_access.md (Chinese Simplified) --- .../translated_docs/zh-CN/cql_db_access.md | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index e6825b4..6b2ec08 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -6,16 +6,15 @@ title: Accessing Database Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: ```bash -cql console -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +cql console 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` Output: - Enter master key(press Enter for default: ""): - - INFO[0010] init config success path=/home/levente/.cql/config.yaml + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.cql/config.yaml INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" - Connected with driver covenantsql (develop-34ae741a-20190416184528) + Connected with driver covenantsql (develop-da3af8f6-20190515152207) Type "help" for help. co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> @@ -24,16 +23,15 @@ Output: Or access as `account2` if it has been granted access permission successfully: ```bash -cql console -config "account2/config.yaml" -dsn 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +cql console -config "account2/config.yaml" 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' ``` Output: - Enter master key(press Enter for default: ""): - - INFO[0010] init config success path=/home/levente/.config/cql/account2/config.yaml + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.config/cql/account2/config.yaml INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" - Connected with driver covenantsql (develop-34ae741a-20190416184528) + Connected with driver covenantsql (develop-da3af8f6-20190515152207) Type "help" for help. co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> @@ -60,30 +58,28 @@ Here is an example of using the interactive console: The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. - usage: cql console [common params] [-dsn dsn_string] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] + usage: cql console [common params] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] [dsn] Console runs an interactive SQL console for CovenantSQL. e.g. - cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + cql console covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c There is also a -command param for SQL script, and a -file param for reading SQL in a file. If those params are set, it will run SQL script and exit without staying console mode. e.g. - cql console -dsn covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c -command "create table test1(test2 int);" + cql console -command "create table test1(test2 int);" covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c - Params: + Console params: -adapter string - Address to serve a database chain adapter, e.g.:7784 + Address to serve a database chain adapter, e.g. :7784 -command string Run only single command (SQL or usql internal command) and exit - -dsn string - Database url -explorer string - Address to serve a database chain explorer, e.g.:8546 + Address serve a database chain explorer, e.g. :8546 -file string Execute commands from file and exit -no-rc - Do not read startup file + Do not read start up file -out string Record stdout to file -single-transaction From a670f957e40fde422f63e3e27518548126bff278 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:35:17 +0800 Subject: [PATCH 352/421] New translations cql_server.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_server.md | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_server.md b/website/translated_docs/zh-CN/cql_server.md index 6d42cd6..a7fe66c 100644 --- a/website/translated_docs/zh-CN/cql_server.md +++ b/website/translated_docs/zh-CN/cql_server.md @@ -11,11 +11,11 @@ title: Local Servers e.g. cql explorer 127.0.0.1:8546 - Params: + Explorer params: -bg-log-level string - Background service log level + Background service log level: trace debug info warning error fatal panic (default "info") -tmp-path string - Background service temp file path, use os.TempDir for default + Background service temp file path, use "dirname $(mktemp -u)" to check it out ## Sub-command `mirror` Complete Parameter @@ -24,13 +24,13 @@ title: Local Servers Mirror subscribes database updates and serves a read-only database mirror. e.g. - cql mirror database_id 127.0.0.1:9389 + cql mirror dsn 127.0.0.1:9389 - Params: + Mirror params: -bg-log-level string - Background service log level + Background service log level: trace debug info warning error fatal panic (default "info") -tmp-path string - Background service temp file path, use os.TempDir for default + Background service temp file path, use "dirname $(mktemp -u)" to check it out ## Sub-command `adapter` Complete Parameter @@ -43,10 +43,10 @@ See for details of adapter server. e.g. cql adapter 127.0.0.1:7784 - Params: + Adapter params: -bg-log-level string - Background service log level + Background service log level: trace debug info warning error fatal panic (default "info") -mirror string - mirror server for the target adapter to query + Mirror server for adapter to query -tmp-path string - Background service temp file path, use os.TempDir for default \ No newline at end of file + Background service temp file path, use "dirname $(mktemp -u)" to check it out \ No newline at end of file From 6b1e301862569e3b211fb7c83dc6a8493ce91253 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 16:48:39 +0800 Subject: [PATCH 353/421] New translations adapter.md (Chinese Simplified) --- website/translated_docs/zh-CN/adapter.md | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 website/translated_docs/zh-CN/adapter.md diff --git a/website/translated_docs/zh-CN/adapter.md b/website/translated_docs/zh-CN/adapter.md new file mode 100644 index 0000000..32c7fa9 --- /dev/null +++ b/website/translated_docs/zh-CN/adapter.md @@ -0,0 +1,59 @@ +--- +id: adapter +title: Adapter +--- + +# Use Adapter to access CovenantSQL + +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. + +## How to use + +First, [Install docker](https://docs.docker.com/install/). + +Secondly, before using CovenantSQL, a proper configuration file and an asymmetric key-pair is required. If no configuration file is specified, CovenantSQL tries to load configuration from `~/.cql/config.yaml`. For configuration file and key-pair generation, please refer to [QuickStart#CreateAccount](./quickstart#CreateAccount) + +### Start adapter using docker + +Following command will use config file `~/.cql/config.yaml` and key-pair `~/.cql/private.key` to start adapter service and serving at `0.0.0.0:11105`. + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + --env COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet +``` + +### Create database + +Create new database using `cql create` command and provide database instance requirements. + +For example, create a single node database instance: + +```bash +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + create -config /app/config.yaml -wait-tx-confirm -db-node 1 +``` + +This command would produce a database connection string (DSN) similar to following example. + +```bash +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +Use DSN to access CovenantSQL using various drivers. + +## Drivers + +1. [Golang](./driver_golang) +2. [Java](./driver_java) +3. [Python](./driver_python) +4. [NodeJS](./driver_js) \ No newline at end of file From 94e49f73d65d1974098e24f7dbadd1c25d399839 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:13:17 +0800 Subject: [PATCH 354/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/quickstart.md | 78 +++++++++---------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/quickstart.md b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md index 88c467c..09f849a 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md @@ -52,12 +52,12 @@ If the problem persists please check out our GitHub page [submit issue](https:// ### Utils -| Tool | Introduction | -| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -| cql | CovenantSQL client, `cql console` The command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | -| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | -| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | -| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | +| Tool | Introduction | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | > Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) @@ -80,20 +80,20 @@ chmod 600 ~/.cql/testnet-conf/private.key > > The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. -## Create a database +## Create a testnet database ```bash -cql create -config=~/.cql/testnet-conf/config.yaml -no-password \ --wait-tx-confirm '{"node":1}' +cql create -config=~/.cql/testnet-conf/config.yaml \ + -db-node 1 -wait-tx-confirm ``` -The command execution takes a little long time, and the console outputs after about 30 seconds: +The command execution takes a little long time, and after about 30 seconds the console outputs something like below: > covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ​ -This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. +This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. > Command execution takes some time, and the general process is: > @@ -103,11 +103,11 @@ This means that you submitted the database `0a10b74439f2376d828c9a70fd538dac4b69 > 4. SQLChain Miners builds a database cluster with Kayak > 5. All Miners are ready to wait for a database request -## Access the database +## Access the testnet database ```bash -cql console -config=~/.cql/testnet-conf/config.yaml -no-password \ --dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +cql console -config=~/.cql/testnet-conf/config.yaml \ + -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. @@ -129,52 +129,50 @@ Please fill in your database ID in the upper right corner of the page. For examp Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): ```bash -cql generate -no-password config +cql generate ``` Output: - INFO[0000] cql build: cql HEAD-48fff30-20190328075135 linux amd64 go1.11.6 - "/home/work/.cql" already exists. - Do you want to delete it? (y or n, press Enter for default n): - y - Generating key pair... - Private key file: /home/work/.cql/private.key - Public key's hex: 024123d10696cf54fbf2b1e2b507ec4d1cbf2b4e87095774ad5fd6376cdae88e87 - Generated key pair. + Generating private key... + Please enter password for new private key + Generated private key. Generating nonce... - INFO[0001] cpu: 2 - INFO[0001] position: 2, shift: 0x0, i: 1 - INFO[0001] position: 0, shift: 0x0, i: 0 - nonce: {{2556203225 0 0 0} 24 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad} - node id: 000000829171cb94b765b4d51f2601aaf2c0f5270827ed97ddbecf0075437dad + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b Generated nonce. Generating config file... Generated config. + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + This command will create a `.cql` directory for you in your `$HOME` directory: - `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; - `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. -Let's continue to generate the account address (also called the wallet address, CovenantSQL address): - -```bash -cql wallet -no-password -``` - -Output: - - wallet address: bc3cba461500f49c2adf6e6e98c1b3513063227063512f0dd6a5160c01de5e3c - +It alse print your wallet address(also called the account address, CovenantSQL address): `Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95` You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). -After up to 2 minutes, you can use the cql command line tool to check the balance: +After up to 2 minutes while requested PTC, you can use the cql command line tool to check the balance: ```bash -cql wallet -no-password -balance all +cql wallet ``` output: From e88d2314a467405f734ca4ca3c768326c0b0d73d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:45 +0800 Subject: [PATCH 355/421] New translations adapter.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/adapter.md | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/adapter.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/adapter.md b/website/translated_docs/zh-CN/version-0.6.0/adapter.md new file mode 100644 index 0000000..bb58d67 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/adapter.md @@ -0,0 +1,60 @@ +--- +id: version-0.6.0-adapter +title: Adapter +original_id: adapter +--- + +# Use Adapter to access CovenantSQL + +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. + +## How to use + +First, [Install docker](https://docs.docker.com/install/). + +Secondly, before using CovenantSQL, a proper configuration file and an asymmetric key-pair is required. If no configuration file is specified, CovenantSQL tries to load configuration from `~/.cql/config.yaml`. For configuration file and key-pair generation, please refer to [QuickStart#CreateAccount](./quickstart#CreateAccount) + +### Start adapter using docker + +Following command will use config file `~/.cql/config.yaml` and key-pair `~/.cql/private.key` to start adapter service and serving at `0.0.0.0:11105`. + +```bash +export adapter_addr=0.0.0.0:11105 +docker rm -f cql-adapter +docker run -itd \ + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ + --env COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --name cql-adapter -p $adapter_addr:4661 \ + covenantsql/covenantsql:testnet +``` + +### Create database + +Create new database using `cql create` command and provide database instance requirements. + +For example, create a single node database instance: + +```bash +docker run -it --rm \ + -v ~/.cql/config.yaml:/app/config.yaml \ + -v ~/.cql/private.key:/app/private.key \ + --entrypoint /app/cql covenantsql/covenantsql:testnet \ + create -config /app/config.yaml -wait-tx-confirm -db-node 1 +``` + +This command would produce a database connection string (DSN) similar to following example. + +```bash +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +``` + +Use DSN to access CovenantSQL using various drivers. + +## Drivers + +1. [Golang](./driver_golang) +2. [Java](./driver_java) +3. [Python](./driver_python) +4. [NodeJS](./driver_js) \ No newline at end of file From ceae95163056685885bb3273e55fb202e0cf21b6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:47 +0800 Subject: [PATCH 356/421] New translations advanced_deployment.md (Chinese Simplified) --- .../version-0.6.0/advanced_deployment.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md new file mode 100644 index 0000000..1fa30f6 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md @@ -0,0 +1,160 @@ +--- +id: version-0.6.0-advanced_deployment +title: Private Deploy +original_id: advanced_deployment +--- + +## Deploy with CovenantSQL Docker + +### Install Docker + +You need to install docker and docker-compose on your machine to deploy CovenantSQL. + +Docker:https://docs.docker.com/install/ + +Docker-Compose:https://docs.docker.com/compose/install/ + +### Download project + +```bash +git clone https://github.com/CovenantSQL/CovenantSQL +cd CovenantSQL +``` + +For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable: + +```bash +export COVENANTSQL_ROOT=$PWD +``` + +### Start Docker container + +There are now two ways to start the CovenantSQL container: + +1. Use a public image on Docker Hub +2. Build a CovenantSQL Docker image + +> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features. + +#### 1. Use a public image on Docker Hub + +Then start directly: + +```bash +make start +``` + +#### 2. Build a CovenantSQL Docker image + +Run CovenantSQL locally by executing the following command + +```bash +make docker # compile a new image from source files +make start +``` + +### Check running status + +Check the container status: + +```bash +docker-compose ps +``` + +Confirm that all components are in the `Up` state + + Name Command State Ports + ------------------------------------------------------------------------------------------------------ + covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp + covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp + covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp + covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp + covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp + covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp + covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp + covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp + covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp + covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp + + +## Operate CovenantSQL + +### Create a database + +Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes. + +e.g.: creating a single-node database instance + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 1 +``` + +> Modify the value of the `create` parameter to create an instance running on multiple nodes +> e.g.: create an instance of two nodes + +```bash +docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 2 +``` + +The command will return the connection string of the created database instance + + covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + + +### Accessing the database + +Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: + +```bash +docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 + ``` + +After that, it will get the following output, and enter the `cql` interactive command line mode + +``` + +Connected with driver covenantsql (develop) Type "help" for help. + +co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + +
The `cql` interactive command line mode is similar to the `mysql` command. For example, create a table named test, view the tables in the database, insert records, and query results etc. + + ```sql + CREATE TABLE test (test TEXT); + SHOW TABLES; + INSERT INTO test VALUES("happy"); + SELECT * FROM test; + + +After that, it will get the following output: + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT); + CREATE TABLE + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES; + name + ------ + test + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy"); + INSERT + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test; + test + ------- + happy + (1 row) + + co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> + + +Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line + +### SQLChain Observer + +The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. + +(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) + +#### Use SQLChain Observer in your browser + +We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain. \ No newline at end of file From 7ee1ea3a4c3fe099f4ef9aeaeb6f8d37e933a92c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:48 +0800 Subject: [PATCH 357/421] New translations cql_account.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_account.md | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_account.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_account.md b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md new file mode 100644 index 0000000..fbf4042 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md @@ -0,0 +1,144 @@ +--- +id: version-0.6.0-cql_account +title: Account Management +original_id: cql_account +--- + +For the TestNet environment, we provide a public account for quick testing. Check the [CovenantSQL TestNet](quickstart) tutorial to find out the private key and config file of the public account. And you can also follow the next section to create an individual account with `cql` command. + +## Creating New Account + +The sub-command `generate` generates a private key file and a config file connecting to the TestNet in the specified directory, e.g.: + +```bash +cql generate +``` + +> Currently, the generated config file is pointed to the TestNet, we will provide options to generated config for Docker Environment later. + +For a complete help message, check [Complete Parameters](#sub-command-generate-complete-parameters). + +Output: + + Generating private key... + Please enter password for new private key + Generated private key. + Generating nonce... + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b + Generated nonce. + Generating config file... + Generated config. + + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + +### Public Key + +Generate command also print public key (in hex string format) of the private key file, e.g.: + +Output: + + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + +> This info is usually not used in common scene. + +### Wallet address + +Generate command shows wallet address (in hex string format) and will store in `config.yaml` file, e.g.: + +Output: + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + +After get a wallet address, you may need to request PTC as below. + +## Sub-command `generate` Complete Parameters + +Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. + + usage: cql generate [common params] [-source template_file] [-miner] [-private existing_private_key] [dest_path] + + Generate generates private.key and config.yaml for CovenantSQL. + You can input a passphrase for local encrypt your private key file by set -with-password + e.g. + cql generate + + or input a passphrase by + + cql generate -with-password + + Generate params: + -miner string + Generate miner config with specified miner address + -private string + Generate config using an existing private key + -source string + Generate config using the specified config template + + +## Mine a Node ID + +The sub-command `idminer` is used to mine another Node ID of a private key (specified by a config file), (also check [Node ID](terms#node-id) for details). e.g.: + +```bash +cql idminer +``` + +Output: + + INFO[0000] cql build: cql develop-34ae741a-20190415161544 linux amd64 go1.11.5 + Enter master key(press Enter for default: ""): + + INFO[0008] init config success path=/home/levente/.cql/config.yaml + INFO[0008] use public key in config file: /home/levente/.cql/config.yaml + INFO[0008] cpu: 8 + INFO[0008] position: 3, shift: 0x20, i: 7 + INFO[0008] position: 0, shift: 0x0, i: 0 + INFO[0008] position: 3, shift: 0x0, i: 6 + INFO[0008] position: 1, shift: 0x0, i: 2 + INFO[0008] position: 2, shift: 0x0, i: 4 + INFO[0008] position: 1, shift: 0x20, i: 3 + INFO[0008] position: 2, shift: 0x20, i: 5 + INFO[0008] position: 0, shift: 0x20, i: 1 + nonce: {{1251426 4506240821 0 0} 25 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e} + node id: 00000041bc2b3de3bcb96328d0004c684628a908f0233eb31fe9998ef0c6288e + + +> This functionality is usually not used in common scene. + +## Sub-command `idminer` Complete Parameters + + usage: cql idminer [common params] [-difficulty number] [-loop [true]] + + IDMiner calculates legal node id and it's nonce. Default parameters are difficulty of 24 and no endless loop. + e.g. + cql idminer -difficulty 24 + + If you want to mine a good id, use: + cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 + + Params: + -difficulty int + the difficulty for a miner to mine nodes and generating a nonce (default 24) + -loop + mining endless loop \ No newline at end of file From a6606fb524c92a3d2bbf3740f345b1af398a8cd4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:49 +0800 Subject: [PATCH 358/421] New translations cql_advance.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_advance.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_advance.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_advance.md b/website/translated_docs/zh-CN/version-0.6.0/cql_advance.md new file mode 100644 index 0000000..7de9d99 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_advance.md @@ -0,0 +1,29 @@ +--- +id: version-0.6.0-cql_advance +title: Advanced Usage +original_id: cql_advance +--- + +Sub-command `rpc` calls the remote process directly in the CovenantSQL network. + +## Sub-command `rpc` Complete Parameter + + usage: cql rpc [common params] [-wait-tx-confirm] [-endpoint rpc_endpoint | -bp] -name rpc_name -req rpc_request + + RPC makes a RPC request to the target endpoint. + e.g. + cql rpc -name 'MCC.QuerySQLChainProfile' \ + -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ + -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' + + RPC params: + -bp + Call block producer node + -endpoint string + RPC endpoint Node ID to do test call + -name string + RPC name to do test call + -req string + RPC request to do test call, in json format + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From d6977ab06804a2da936dbe5eb0314e3f71602c98 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:50 +0800 Subject: [PATCH 359/421] New translations cql_db_access.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_db_access.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md b/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md new file mode 100644 index 0000000..56e0bc9 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md @@ -0,0 +1,89 @@ +--- +id: version-0.6.0-cql_db_access +title: Accessing Database +original_id: cql_db_access +--- + +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: + +```bash +cql console 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-da3af8f6-20190515152207) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Or access as `account2` if it has been granted access permission successfully: + +```bash +cql console -config "account2/config.yaml" 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-da3af8f6-20190515152207) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +## Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [common params] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] [dsn] + + Console runs an interactive SQL console for CovenantSQL. + e.g. + cql console covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + There is also a -command param for SQL script, and a -file param for reading SQL in a file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -command "create table test1(test2 int);" covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + Console params: + -adapter string + Address to serve a database chain adapter, e.g. :7784 + -command string + Run only single command (SQL or usql internal command) and exit + -explorer string + Address serve a database chain explorer, e.g. :8546 + -file string + Execute commands from file and exit + -no-rc + Do not read start up file + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable \ No newline at end of file From 22fcdc3afbe83cca6dc5d12aae6c4d6b247fa3cd Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:52 +0800 Subject: [PATCH 360/421] New translations cql_db_manage.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_db_manage.md | 244 ++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md b/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md new file mode 100644 index 0000000..627738a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md @@ -0,0 +1,244 @@ +--- +id: version-0.6.0-cql_db_manage +title: Database Management +original_id: cql_db_manage +--- + +## Creating Database + +Like `transfer`, `create` takes several parameters. e.g. Create a database with one miner node: + +```bash +cql create -db-node 1 +``` + +Output: + + INFO[0000] Geting bp address from dns: bp00.testnet.gridb.io + INFO[0048] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 + INFO init config success path=~/.cql/config.yaml + INFO create database requested + + The newly created database is: "covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4" + The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console` + or any command, or be used in website like https://web.covenantsql.io + + +Here `covenantsql://962bbb3a8028a203e99121d23173a38fa24a670d52c8775a9d987d007a767ce4` is the database source name (DSN) of the created database. And the `covenantsql` part is the scheme, which can be `cql` in abbreviation. The hex string after `://` is the database address, which can be used as a receiver address in `transfer` command. + +The sub-command `create` sends transactions to block producers to create databases, so it has a `wait-tx-confirm` parameter too. + +For a complete help message, check [Complete Parameters](#sub-command-create-complete-parameters). + +## Billing + +CovenantSQL uses Gas for billing just like the [Ethereum Gas](https://www.ethos.io/what-is-ethereum-gas/). The gas unit (a.k.a., the `Gas-Price`) in stable token `Particle` is specified while creating the database, and its corresponding field is `-db-gas-price`. If not specified in the parameter, it will be set as 1 by default. Another billing-related field is `-db-advance-payment`, which will be used as deposit and query expending. The default advance payment is 20,000,000. Creating a database with specified `Gas-Price` and `Advance-Payment`: + +```bash +cql create -db-node 2 -db-gas-price 5 -db-advance-payment 500000000 +``` + +Thus we created a new database with `Gas-Price` 5 and `Advance-Payment` 500,000,000. Note that when the CovenantSQL network is short of miner resources, setting a higher `Gas-Price` will help your creation request to be accepted earlier, but it will cost you more tokens of course. + +> At present, we only accept the CovenantSQL stable token Particle for database billing. More token types will be supported soon. + +And the billing is processed as following: + +- For a Read request, the result `rows_count` is counted as the `Gas` cost +- For a Write request, the result `affected_rows` is counted as the `Gas` cost +- The SQLChain miner does periodic billing, sums up, and reports the `Gas` cost to the main chain, and the main chain verifies and deducts `Gas` * `Gas Price` tokens from the user accounts + +## ~~Deleting Database~~ + +~~Not yet implemented.~~ + +## Granting Permission + +### Access Permission + +CovenantSQL database has 3 kinds of access permission: + +- `Admin` +- `Write` +- `Read` +- `Void` (for none) + +Among them, `Admin` is the permission that can assign permissions (`Admin`, `Write`, or `Read`) to the other accounts. `Admin` and `Write` allows the write queries (such as `CREATE`, `INSERT`, and etc.). `Admin` and `Read` allows the read queries (such as `SHOW`, `SELECT`, and etc.). If you want to allow a user to read/write the database but not allow to modify the permissions of itself or other accounts, you can assign the user permission as `Read,Write`. `Void` is a special kind of permission which means 'no permission'. Once the `Admin` sets the permission of an account as `Void`, it will no longer able to read or write the database. The account who creates the database will be granted the initial `Admin` permission by default. + +Assume that you have created a database `covenantsql:\\4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5` with default account, and have generated another account under directory `account2` which has the address `011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6`. Now you can grant permissions to `accounts` to access the database, with parameters as following: + +```bash +`-to-dsn` Target database adderss to give permission +`-to-user` Target wallet address to get permission +`-perm` Permission, separated by commas +``` + +Pass the parameter to `grant`: + +```bash +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Read,Write" +``` + +Output: + + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in grant permission on target database + + +Or revoke the permission: + +```bash +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Void" +``` + +Output: + + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0003] Self register to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in grant permission on target database + + +The sub-command `grant` sends transactions to block producers to request permission granting, so it has a `wait-tx-confirm` parameter too. + +Since the database separately keeps billing for each user, you need to transfer tokens to the database (as user deposit and advance payment) from the new account before it can actually get access to the database. The minimum amount of deposit and advance payment can be calculated by: `gas_price*number_of_miner*120000`. + +Transferring from `account2` to the database: + +```bash +cql transfer -config "account2/config.yaml" \ + -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -amount 90000000 \ + -token Particle +``` + +### SQL White List + +CovenantSQL supports white list setting for each of its users. By setting up SQL white list, you can further limit the access permission of a user to a given list of SQL Patterns with assignable parameters. With this feature, your database can be further secured because it avoids important data breach and accidentally updating/deleting. + +Adding a white list: + +```bash +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm ' +{ + "patterns": [ + "SELECT COUNT(1) FROM a", + "SELECT * FROM a WHERE id = ? LIMIT 1" + ], + "role": "Read,Write" +} +' +``` + +*SQL White List is an extension of the database permission system. It currently doesn't support incrementally updating, so you need to provide the complete permission information each time you use the `grant` sub-command* + +Cleaning the white list: + +```bash +
cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm ' +{ + "patterns": nil, + "role": "Read,Write" +} +' + + or + +cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5 \ + -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ + -perm "Read,Write" +``` + +Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. + +## Sub-command `create` Complete Parameters + + usage: cql create [common params] [-wait-tx-confirm] [db_meta_params] + + Create command creates a CovenantSQL database by database meta params. The meta info must include + node count. + e.g. + cql create -db-node 2 + + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the creation takes effect. + e.g. + cql create -wait-tx-confirm -db-node 2 + + DB meta params: + -db-advance-payment uint + Customized advance payment + -db-consistency-level float + Consistency level, node*consistency_level is the node count to perform strong consistency + -db-encrypt-key string + Encryption key for persistence data + -db-eventual-consistency + Use eventual consistency to sync among miner nodes + -db-gas-price uint + Customized gas price + -db-isolation-level int + Isolation level in a single node + -db-load-avg-per-cpu float + Minimum idle CPU requirement, 0 for none + -db-memory uint + Minimum memory requirement, 0 for none + -db-node uint + Target node count + -db-space uint + Minimum disk space requirement, 0 for none + -db-target-miners value + List of target miner addresses(separated by ',') + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `drop` Complete Parameters + + usage: cql drop [common params] [-wait-tx-confirm] dsn + + Drop drops a CovenantSQL database by DSN or database ID. + e.g. + cql drop covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the drop operation takes effect. + e.g. + cql drop -wait-tx-confirm covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + Drop params: + -wait-tx-confirm + Wait for transaction confirmation + + +## Sub-command `grant` Complete Parameters + + usage: cql grant [common params] [-wait-tx-confirm] [-to-user wallet] [-to-dsn dsn] [-perm perm_struct] + + Grant grants specific permissions for the target user on target dsn. + e.g. + cql grant -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct + + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the permission takes effect. + e.g. + cql grant -wait-tx-confirm -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="covenantsql://xxxx" -perm perm_struct + + Grant params: + -perm string + Permission type struct for grant. + -to-dsn string + Target database dsn to grant permission. + -to-user string + Target address of an user account to grant permission. + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From ec925d9ff1233855fdb40d000f044d9b821aec00 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:53 +0800 Subject: [PATCH 361/421] New translations cql_intro.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_intro.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_intro.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md b/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md new file mode 100644 index 0000000..cfda497 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md @@ -0,0 +1,32 @@ +--- +id: version-0.6.0-cql_intro +title: Overview +original_id: cql_intro +--- + +CovenantSQL provides a `cql` command line toolset for terminal users to access and manage user accounts, wallet balances, and databases. Check the complete toolset installation tutorial at \[CovenantSQL Toolset installation\](quickstart#工具包安装). + +## Private Key and Config File + +The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: + +- `private.key`:a private key file which is generated while creating an account, be sure to keep it safe +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment](deployment)) + +For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. + +## Common Parameters for Sub-commands + +The following parameters are commonly used by `cql` sub-commands: + + -config string + Config file for covenantsql (Usually no need to set, default is enough.) (default "~/.cql/config.yaml") + -with-password + Use passphrase for private.key + -password string + Master key for covenantsql (NOT SAFE, for debugging or script mode only) + -help + Show help message + + +Note that the private key file path is specified in the config file, and its default value is `./private.key`, indicating that it's located in the same directory of the config. So usually we put the private key file together with config, instead of using an individual parameter to specify the private key file. \ No newline at end of file From 6cf64413bb30cb7fddfb3a49ec5642bab99a7928 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:54 +0800 Subject: [PATCH 362/421] New translations cql_server.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_server.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_server.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_server.md b/website/translated_docs/zh-CN/version-0.6.0/cql_server.md new file mode 100644 index 0000000..033770a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_server.md @@ -0,0 +1,53 @@ +--- +id: version-0.6.0-cql_server +title: Local Servers +original_id: cql_server +--- + +## Sub-command `explorer` Complete Parameter + + usage: cql explorer [common params] [-tmp-path path] [-bg-log-level level] listen_address + + Explorer serves a SQLChain web explorer. + e.g. + cql explorer 127.0.0.1:8546 + + Explorer params: + -bg-log-level string + Background service log level: trace debug info warning error fatal panic (default "info") + -tmp-path string + Background service temp file path, use "dirname $(mktemp -u)" to check it out + + +## Sub-command `mirror` Complete Parameter + + usage: cql mirror [common params] [-tmp-path path] [-bg-log-level level] dsn listen_address + + Mirror subscribes database updates and serves a read-only database mirror. + e.g. + cql mirror dsn 127.0.0.1:9389 + + Mirror params: + -bg-log-level string + Background service log level: trace debug info warning error fatal panic (default "info") + -tmp-path string + Background service temp file path, use "dirname $(mktemp -u)" to check it out + + +## Sub-command `adapter` Complete Parameter + +See for details of adapter server. + + usage: cql adapter [common params] [-tmp-path path] [-bg-log-level level] [-mirror addr] listen_address + + Adapter serves a SQLChain adapter. + e.g. + cql adapter 127.0.0.1:7784 + + Adapter params: + -bg-log-level string + Background service log level: trace debug info warning error fatal panic (default "info") + -mirror string + Mirror server for adapter to query + -tmp-path string + Background service temp file path, use "dirname $(mktemp -u)" to check it out \ No newline at end of file From a4dc7f5b89bea7ad936ee958a0c2c89f3183d7eb Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 17:22:56 +0800 Subject: [PATCH 363/421] New translations cql_wallet.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_wallet.md | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md new file mode 100644 index 0000000..0e1d4ab --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md @@ -0,0 +1,131 @@ +--- +id: version-0.6.0-cql_wallet +title: Wallet Management +original_id: cql_wallet +--- + +## Wallet Address + +Once the private key and config file is set, you can use sub-command `wallet` to check the wallet address of the account: + +```bash +cql wallet +``` + +Output: + + INFO[0000] Geting bp address from dns: bp00.testnet.gridb.io + INFO[0003] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 + INFO init config success path=~/.cql/config.yaml + + + wallet address: 290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613 + Particle balance is: 100000000 + Wave balance is: 0 + found no related database + + +The wallet address of the test account here is `290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613`. And balances are also shown. + +## Wallet Balances + +CovenantSQL currently supports 5 types of tokens: + +- `Particle` +- `Wave` +- `Bitcoin` +- `Ether` +- `EOS` + +Among them, `Particle` and `Wave` are the token types used by CovenantSQL. You can also check the balance of a specified type of token, e.g., checking the balance of `Bitcoin`: + +```bash +cql wallet -token Bitcoin +``` + +Output: + + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0006] Register self to blockproducer: 0000000000293f7216362791b6b1c9772184d6976cb34310c42547735410186c + INFO init config success path=~/.cql/config.yaml + + wallet address: 290f7dbbff2aa0d5a5af65f4caa0bfd68663f97f9b08d0ee71e76a172349b613 + Bitcoin balance is: 0 + + +## Transferring Tokens to Another Account + +Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: + +```bash +cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -type Particle +``` + +`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-type` is for token type + +## Transferring Tokens to a database + +If you want to transfer token to a database address, replace `-to-user` to `-to-dsn`, and set a CovenantSQL dsn string. e.g. + +```bash +cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -type Particle +``` + +While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. + +> Check more detailed knowledge about [Deposit and Advance Payment](terms#deposit-and-advance-payment). + +Output: + + INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io + INFO[0043] Register self to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb + INFO init config success path=~/.cql/config.yaml + INFO succeed in sending transaction to CovenantSQL + + +Note that the above output message indicates that the transfer request is successfully sent to CovenantSQL network, but it will take a while before the block producers actually execute and confirm the transaction to take effect. You can use the `cql wallet -token ` command again to check if the request takes effect, or add `-wait-tx-confirm` parameter to make `cql` wait for transaction confirmation before exit. + +## Sub-command `wallet` Complete Parameters + + usage: cql wallet [common params] [-token type] [-dsn dsn] + + Wallet gets the CovenantSQL wallet address and the token balances of the current account. + e.g. + cql wallet + + cql wallet -token Particle + + cql wallet -dsn "covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c" + + Wallet params: + -dsn string + Show specified database deposit + -token string + Get specific token's balance of current account, e.g. Particle, Wave, All + + +## Sub-command `transfer` Complete Parameters + + usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-type token_type] + + Transfer transfers your token to the target account or database. + The command arguments are target wallet address(or dsn), amount of token, and token type. + e.g. + cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + + Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction + confirmation before the transfer takes effect. + e.g. + cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + + Transfer params: + -amount uint + Token account to transfer. + -to-dsn string + Target database dsn to transfer token. + -to-user string + Target address of an user account to transfer token. + -type string + Token type to transfer. + -wait-tx-confirm + Wait for transaction confirmation \ No newline at end of file From 7a6fdf88d50d43e615c5c4d2ca9b567b47b5b029 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:51:49 +0800 Subject: [PATCH 364/421] New translations advanced_deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/advanced_deployment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/advanced_deployment.md b/website/translated_docs/zh-CN/advanced_deployment.md index a987a4b..402c0fc 100644 --- a/website/translated_docs/zh-CN/advanced_deployment.md +++ b/website/translated_docs/zh-CN/advanced_deployment.md @@ -85,14 +85,14 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 1 +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 1 ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 2 +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 2 ``` The command will return the connection string of the created database instance @@ -105,7 +105,7 @@ The command will return the connection string of the created database instance Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```bash -docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode From 4c134dd1051aeb2fb3fc2b7ce964bdb08b044651 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:20 +0800 Subject: [PATCH 365/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index f02f376..d10956b 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -21,7 +21,7 @@ Please choose the installation method according to the operating system platform - non-Homebrew users can run: ```bash - sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + sudo bash -c 'curl -L "https://mac.gridb.io/cql" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` @@ -30,7 +30,7 @@ Please choose the installation method according to the operating system platform - Just run: ```bash - sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + sudo bash -c 'curl -L "https://linux.gridb.io/cql" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` @@ -106,7 +106,7 @@ This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d8 ```bash cql console -config=~/.cql/testnet-conf/config.yaml \ - -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. @@ -125,7 +125,7 @@ Please fill in your database ID in the upper right corner of the page. For examp ## Create your own account -Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (default empty passphrase for private.key, you can add `-with-password` to set passphrase): ```bash cql generate From ad5e3a25afde4406c000c0b0c46baf347ad1dd0d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:25 +0800 Subject: [PATCH 366/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md index 09fb550..6925f76 100644 --- a/website/translated_docs/zh-CN/cql_account.md +++ b/website/translated_docs/zh-CN/cql_account.md @@ -69,7 +69,7 @@ Output: https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 -After get a wallet address, you may need to request PTC as below. +After get a wallet address, you may need to request PTC as above. ## Sub-command `generate` Complete Parameters From ce2103a2de4173cad0ed0d3a31f28c96c6494cc8 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:42 +0800 Subject: [PATCH 367/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index 58f17a9..c57fda5 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -57,17 +57,17 @@ Output: Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: ```bash -cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -type Particle +cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -token Particle ``` -`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-type` is for token type +`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-token` is for token type ## Transferring Tokens to a database If you want to transfer token to a database address, replace `-to-user` to `-to-dsn`, and set a CovenantSQL dsn string. e.g. ```bash -cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -type Particle +cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -token Particle ``` While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. @@ -105,17 +105,17 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `transfer` Complete Parameters - usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-type token_type] + usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-token token_type] Transfer transfers your token to the target account or database. The command arguments are target wallet address(or dsn), amount of token, and token type. e.g. - cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -token=Particle Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the transfer takes effect. e.g. - cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -token=Particle Transfer params: -amount uint @@ -124,7 +124,7 @@ Note that the above output message indicates that the transfer request is succes Target database dsn to transfer token. -to-user string Target address of an user account to transfer token. - -type string + -token string Token type to transfer. -wait-tx-confirm Wait for transaction confirmation \ No newline at end of file From 1b5a98c9b14516d22c68d96d1bc9e3c0caf7558d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:43 +0800 Subject: [PATCH 368/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/quickstart.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/quickstart.md b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md index 09f849a..f4ef129 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/quickstart.md +++ b/website/translated_docs/zh-CN/version-0.6.0/quickstart.md @@ -22,7 +22,7 @@ Please choose the installation method according to the operating system platform - non-Homebrew users can run: ```bash - sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.osx-amd64.tar.gz" | \ + sudo bash -c 'curl -L "https://mac.gridb.io/cql" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` @@ -31,7 +31,7 @@ Please choose the installation method according to the operating system platform - Just run: ```bash - sudo bash -c 'curl -L "https://bintray.com/covenantsql/bin/download_file?file_path=CovenantSQL-v0.5.0.linux-amd64.tar.gz" | \ + sudo bash -c 'curl -L "https://linux.gridb.io/cql" | \ tar xzv -C /usr/local/bin/ --strip-components=1' ``` @@ -107,7 +107,7 @@ This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d8 ```bash cql console -config=~/.cql/testnet-conf/config.yaml \ - -dsn covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 ``` After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. @@ -126,7 +126,7 @@ Please fill in your database ID in the upper right corner of the page. For examp ## Create your own account -Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (you will be asked to set the master password, you can add `-no-password` to leave blank): +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (default empty passphrase for private.key, you can add `-with-password` to set passphrase): ```bash cql generate From a5402ac73b48d7842835a0e04b4e3c946cf10040 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:45 +0800 Subject: [PATCH 369/421] New translations advanced_deployment.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/advanced_deployment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md index 1fa30f6..766a336 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md +++ b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md @@ -86,14 +86,14 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 1 +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 1 ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 2 +docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 2 ``` The command will return the connection string of the created database instance @@ -106,7 +106,7 @@ The command will return the connection string of the created database instance Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```bash -docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode From 7255e969a312a182efaba043f30036e5fc264c31 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:47 +0800 Subject: [PATCH 370/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/cql_account.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_account.md b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md index fbf4042..1c64318 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_account.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md @@ -70,7 +70,7 @@ Output: https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 -After get a wallet address, you may need to request PTC as below. +After get a wallet address, you may need to request PTC as above. ## Sub-command `generate` Complete Parameters From 8092f84da14ced0df5e96bdf0239af3cf01f7810 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 20:52:51 +0800 Subject: [PATCH 371/421] New translations cql_wallet.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/cql_wallet.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md index 0e1d4ab..9ca667e 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md @@ -58,17 +58,17 @@ Output: Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: ```bash -cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -type Particle +cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -token Particle ``` -`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-type` is for token type +`-to-user` is set for other user's wallet address, `-amount` param is for token count, and `-token` is for token type ## Transferring Tokens to a database If you want to transfer token to a database address, replace `-to-user` to `-to-dsn`, and set a CovenantSQL dsn string. e.g. ```bash -cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -type Particle +cql transfer -to-dsn covenantsql://0bfea233d20676bb848b66d072bb768945507bb8a3b8b22b13133cde0583e208 -amount 1000000 -token Particle ``` While transferring to a database, the tokens will be used as the deposit and advance payment of that database for the sender. @@ -106,17 +106,17 @@ Note that the above output message indicates that the transfer request is succes ## Sub-command `transfer` Complete Parameters - usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-type token_type] + usage: cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-token token_type] Transfer transfers your token to the target account or database. The command arguments are target wallet address(or dsn), amount of token, and token type. e.g. - cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -token=Particle Since CovenantSQL is built on top of blockchains, you may want to wait for the transaction confirmation before the transfer takes effect. e.g. - cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -type=Particle + cql transfer -wait-tx-confirm -to-dsn=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -token=Particle Transfer params: -amount uint @@ -125,7 +125,7 @@ Note that the above output message indicates that the transfer request is succes Target database dsn to transfer token. -to-user string Target address of an user account to transfer token. - -type string + -token string Token type to transfer. -wait-tx-confirm Wait for transaction confirmation \ No newline at end of file From c2ddb63b57df6ec3f8f2d7e50e40893fa38cee1a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:21:09 +0800 Subject: [PATCH 372/421] New translations advanced_deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/advanced_deployment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/advanced_deployment.md b/website/translated_docs/zh-CN/advanced_deployment.md index 402c0fc..f1e2c78 100644 --- a/website/translated_docs/zh-CN/advanced_deployment.md +++ b/website/translated_docs/zh-CN/advanced_deployment.md @@ -85,14 +85,14 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 1 +cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 1 ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 2 +cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 2 ``` The command will return the connection string of the created database instance @@ -105,7 +105,7 @@ The command will return the connection string of the created database instance Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```bash -docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +cql console -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode From 814108a7893619511e882b1aaf964a4319c62d51 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:21:14 +0800 Subject: [PATCH 373/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_java.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index bd73fcb..8bd7e56 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -26,7 +26,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo + https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo true @@ -52,7 +52,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo' + url 'https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo' } } From 85672924dbbfa1c37b91e6e99e8e3de6e499350a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:22:01 +0800 Subject: [PATCH 374/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 2e48080..85ec922 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -25,7 +25,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo + https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo true @@ -51,7 +51,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.githack.com/CovenantSQL/covenant-connector/master/covenantsql-java-connector/mvn-repo' + url 'https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo' } } From 72ef58d978d60cd7c95ae2c07b11dd28d1a9e13b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:27:03 +0800 Subject: [PATCH 375/421] New translations advanced_deployment.md (Chinese Simplified) --- .../zh-CN/version-0.6.0/advanced_deployment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md index 766a336..a780830 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md +++ b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md @@ -86,14 +86,14 @@ Create a DB instance by using the `cql` command and using the `create` parameter e.g.: creating a single-node database instance ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 1 +cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 1 ``` > Modify the value of the `create` parameter to create an instance running on multiple nodes > e.g.: create an instance of two nodes ```bash -docker exec -it covenantsql_adapter /app/cql create -config /app/node_adapter/config.yaml -db-node 2 +cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 2 ``` The command will return the connection string of the created database instance @@ -106,7 +106,7 @@ The command will return the connection string of the created database instance Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access: ```bash -docker exec -it covenantsql_adapter /app/cql console -config /app/node_adapter/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 +cql console -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 ``` After that, it will get the following output, and enter the `cql` interactive command line mode From bc6fcc675022740c4225de99c27482bd6d933337 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:46:45 +0800 Subject: [PATCH 376/421] New translations advanced_deployment.md (Chinese Simplified) --- website/translated_docs/zh-CN/advanced_deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/advanced_deployment.md b/website/translated_docs/zh-CN/advanced_deployment.md index f1e2c78..7bbc350 100644 --- a/website/translated_docs/zh-CN/advanced_deployment.md +++ b/website/translated_docs/zh-CN/advanced_deployment.md @@ -152,7 +152,7 @@ Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command l The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. -(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) +(For details on rights management, please refer to [Database Permission Managemen](cql_db_manage#granting-permission)) #### Use SQLChain Observer in your browser From ddba1fdd13c1695bb32a0b7485917d48b7bbfc0b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 15 May 2019 22:46:58 +0800 Subject: [PATCH 377/421] New translations advanced_deployment.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.6.0/advanced_deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md index a780830..e094f97 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md +++ b/website/translated_docs/zh-CN/version-0.6.0/advanced_deployment.md @@ -153,7 +153,7 @@ Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command l The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated. -(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理)) +(For details on rights management, please refer to [Database Permission Managemen](cql_db_manage#granting-permission)) #### Use SQLChain Observer in your browser From ab03dec48ff543593264e43ccc9e24731777a1c6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 16 May 2019 10:41:08 +0800 Subject: [PATCH 378/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_java.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index 8bd7e56..544369c 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -26,7 +26,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo + https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo true @@ -52,7 +52,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo' + url 'https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo' } } From 6759934bbd34a17a4d65d4aae7736550a9740f28 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 16 May 2019 10:41:32 +0800 Subject: [PATCH 379/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 85ec922..6e888bb 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -25,7 +25,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo + https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo true @@ -51,7 +51,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.githack.com/CovenantSQL/covenant-connector/mvn-repo' + url 'https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo' } } From d953ea113de63ee17e914dd4dcc5d5f784068c62 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 23 May 2019 19:31:04 +0800 Subject: [PATCH 380/421] New translations cql_db_manage.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_manage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_manage.md b/website/translated_docs/zh-CN/cql_db_manage.md index 3e5499a..7a06d00 100644 --- a/website/translated_docs/zh-CN/cql_db_manage.md +++ b/website/translated_docs/zh-CN/cql_db_manage.md @@ -146,7 +146,7 @@ Cleaning the white list: -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ -perm ' { - "patterns": nil, + "patterns": null, "role": "Read,Write" } ' @@ -158,7 +158,7 @@ cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e3 -perm "Read,Write" ``` -Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. +Either setting the `pattern` field to `null` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. ## Sub-command `create` Complete Parameters From 95162045fe7839683e4ef41999ce373d5226d889 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 23 May 2019 19:31:08 +0800 Subject: [PATCH 381/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_access.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index 6b2ec08..f7b18d0 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -20,7 +20,7 @@ Output: co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -Or access as `account2` if it has been granted access permission successfully: +Or access as `account2` (Should been granted access permission and transfered deposit token to the database successfully in last section): ```bash cql console -config "account2/config.yaml" 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' @@ -58,7 +58,7 @@ Here is an example of using the interactive console: The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. - usage: cql console [common params] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] [dsn] + usage: cql console [common params] [Console params] dsn Console runs an interactive SQL console for CovenantSQL. e.g. From 3dae3986ac0b3378647c4033634f9d39c1ecd785 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 23 May 2019 19:31:12 +0800 Subject: [PATCH 382/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_account.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_account.md b/website/translated_docs/zh-CN/cql_account.md index 6925f76..a9fcc19 100644 --- a/website/translated_docs/zh-CN/cql_account.md +++ b/website/translated_docs/zh-CN/cql_account.md @@ -73,7 +73,7 @@ After get a wallet address, you may need to request PTC as above. ## Sub-command `generate` Complete Parameters -Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. +Also see [Common Parameters for Sub-commands](cql_intro#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. usage: cql generate [common params] [-source template_file] [-miner] [-private existing_private_key] [dest_path] From 969dedcbac3403b2d421d7409a17b6d548356e64 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 23 May 2019 19:31:27 +0800 Subject: [PATCH 383/421] New translations cql_intro.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_intro.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_intro.md b/website/translated_docs/zh-CN/cql_intro.md index c88cccd..98eb6a6 100644 --- a/website/translated_docs/zh-CN/cql_intro.md +++ b/website/translated_docs/zh-CN/cql_intro.md @@ -10,10 +10,19 @@ CovenantSQL provides a `cql` command line toolset for terminal users to access a The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: - `private.key`:a private key file which is generated while creating an account, be sure to keep it safe -- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment](deployment)) +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Private Deploy](advanced_deployment)) For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. +## Command Format + +The `cql` command has more than a dozen subcommands, each one follows the same command format. e.g: + + cql sub-command [common parameters] [subcommand parameters] arguments + + +The content of `arguments` may be empty, but it must be placed at the end of the command when it is not empty. + ## Common Parameters for Sub-commands The following parameters are commonly used by `cql` sub-commands: From 6423e80295fc09d9be32ba6d52a4a40f7233dcd5 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 23 May 2019 19:31:28 +0800 Subject: [PATCH 384/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/cql_wallet.md b/website/translated_docs/zh-CN/cql_wallet.md index c57fda5..5053648 100644 --- a/website/translated_docs/zh-CN/cql_wallet.md +++ b/website/translated_docs/zh-CN/cql_wallet.md @@ -54,7 +54,7 @@ Output: ## Transferring Tokens to Another Account -Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: +Once you get tokens from [TestNet](quickstart) or [Private Deploy](advanced_deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: ```bash cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -token Particle From 29288e41a13941b6d2317fcb7d9a5688d3c0e014 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 24 May 2019 09:59:22 +0800 Subject: [PATCH 385/421] New translations cql_intro.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.6.0/cql_intro.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md b/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md index cfda497..e83c52b 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_intro.md @@ -11,10 +11,19 @@ CovenantSQL provides a `cql` command line toolset for terminal users to access a The `cql` command needs to rely on a private key file `private.key` and a config file `config.yaml`: - `private.key`:a private key file which is generated while creating an account, be sure to keep it safe -- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Docker Environment](deployment)) +- `config.yaml`:mainly used to config the CovenantSQL network for `cql` command to connect (e.g., the [TestNet](quickstart) or the [Private Deploy](advanced_deployment)) For security, the private key file is usually encrypted with a master key. A master key is individually chosen by the user while creating an account and is memorized or kept somewhere by the user -- note that the config file will not keep the master key. When the private key is required by the `cql` command, it will ask the user to input the master key to decrypt the private key file. +## Command Format + +The `cql` command has more than a dozen subcommands, each one follows the same command format. e.g: + + cql sub-command [common parameters] [subcommand parameters] arguments + + +The content of `arguments` may be empty, but it must be placed at the end of the command when it is not empty. + ## Common Parameters for Sub-commands The following parameters are commonly used by `cql` sub-commands: From ebbcd21b10ea55cb6a5621b4a3b6bb524cb7be5a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 24 May 2019 09:59:23 +0800 Subject: [PATCH 386/421] New translations cql_db_manage.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md b/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md index 627738a..8fd2f9a 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_db_manage.md @@ -147,7 +147,7 @@ Cleaning the white list: -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 \ -perm ' { - "patterns": nil, + "patterns": null, "role": "Read,Write" } ' @@ -159,7 +159,7 @@ cql grant -to-dsn covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e3 -perm "Read,Write" ``` -Either setting the `pattern` field to `nil` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. +Either setting the `pattern` field to `null` or just resetting the user permission directly, will eliminate the white list and give back the access permission to the user. ## Sub-command `create` Complete Parameters From 150409b591de3d51b8a26c7be96586b3691c4ec0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 24 May 2019 09:59:24 +0800 Subject: [PATCH 387/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md b/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md index 56e0bc9..b6b90e4 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_db_access.md @@ -21,7 +21,7 @@ Output: co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> -Or access as `account2` if it has been granted access permission successfully: +Or access as `account2` (Should been granted access permission and transfered deposit token to the database successfully in last section): ```bash cql console -config "account2/config.yaml" 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' @@ -59,7 +59,7 @@ Here is an example of using the interactive console: The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. - usage: cql console [common params] [-command sqlcommand] [-file filename] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [-adapter adapter_addr] [dsn] + usage: cql console [common params] [Console params] dsn Console runs an interactive SQL console for CovenantSQL. e.g. From 388d20829bef0710e7f02473aa489d8a65f26c18 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 24 May 2019 09:59:26 +0800 Subject: [PATCH 388/421] New translations cql_account.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/cql_account.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_account.md b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md index 1c64318..77608b5 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_account.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_account.md @@ -74,7 +74,7 @@ After get a wallet address, you may need to request PTC as above. ## Sub-command `generate` Complete Parameters -Also see [Common Parameters for Sub-commands](#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. +Also see [Common Parameters for Sub-commands](cql_intro#common-parameters-for-sub-commands). We will not mention this again in the later sub-command introductions. usage: cql generate [common params] [-source template_file] [-miner] [-private existing_private_key] [dest_path] From 7339c9276c991b8f7637eff0814ee05c6db95279 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 24 May 2019 09:59:57 +0800 Subject: [PATCH 389/421] New translations cql_wallet.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md index 9ca667e..73fb204 100644 --- a/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md +++ b/website/translated_docs/zh-CN/version-0.6.0/cql_wallet.md @@ -55,7 +55,7 @@ Output: ## Transferring Tokens to Another Account -Once you get tokens from [TestNet](quickstart) or [Docker Environment](deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: +Once you get tokens from [TestNet](quickstart) or [Private Deploy](advanced_deployment), you can use the `transfer` sub-command to transfer tokens to another account. The command takes 3 main parameters, e.g.: ```bash cql transfer -to-user 011f72fea9efa1a49a6663d66e514a34e45e426524c13335cf20bec1b47d10d6 -amount 1000000 -token Particle From d490b5da841631e099e2efe7068a4ee8d7130aae Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:02 +0800 Subject: [PATCH 390/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/driver_python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md index 417c6f9..28b6efc 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_python.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_python.md @@ -6,7 +6,7 @@ original_id: driver_python ## Use Python to access CovenantSQL -Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). +Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/cql-python-driver) to access CovenantSQL through [Adapter](./adapter). ### Compatibility From 383ed62bdd9effc9ed4cd5c0fd804cbf2b9fb3cd Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:04 +0800 Subject: [PATCH 391/421] New translations driver_java.md (Chinese Simplified) --- .../translated_docs/zh-CN/version-0.5.0/driver_java.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md index 544369c..572047d 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/driver_java.md +++ b/website/translated_docs/zh-CN/version-0.5.0/driver_java.md @@ -26,7 +26,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo + https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo true @@ -52,7 +52,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo' + url 'https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo' } } @@ -63,6 +63,6 @@ dependencies { ### Examples -1. [JDBC Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) -2. [MyBatis Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +1. [JDBC Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) 3. [SpringBoot + MyBatis Project Example](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From de5f4afbbce491877377a1cd00a72afd579f9bf0 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:17 +0800 Subject: [PATCH 392/421] New translations getting-started-zh.md (Chinese Simplified) --- .../zh-CN/version-0.5.0/bck/getting-started-zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md index 398ad03..e8530b1 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/getting-started-zh.md @@ -109,8 +109,8 @@ CovenantSQL 是一个运行在 Internet 上的开放网络,主要有以下三 ### 使用数据库驱动访问数据库 * [Go](./development-golang-client-zh.md) -* [Java](https://github.com/CovenantSQL/covenant-connector) -* [Python](https://github.com/CovenantSQL/python-driver) +* [Java](https://github.com/CovenantSQL/cql-java-driver) +* [Python](https://github.com/CovenantSQL/cql-python-driver) * [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) ## 通过区块浏览器查看您的数据库操作记录 From 206c81ec95e099721394ff6f5ea276dc023517d7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:24 +0800 Subject: [PATCH 393/421] New translations driver_python.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/driver_python.md b/website/translated_docs/zh-CN/driver_python.md index 7fb17e3..e68f269 100644 --- a/website/translated_docs/zh-CN/driver_python.md +++ b/website/translated_docs/zh-CN/driver_python.md @@ -5,7 +5,7 @@ title: Python ## Use Python to access CovenantSQL -Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/python-driver) to access CovenantSQL through [Adapter](./adapter). +Developers could use [PyCovenantSQL](https://github.com/CovenantSQL/cql-python-driver) to access CovenantSQL through [Adapter](./adapter). ### Compatibility From 9383923bf2ed4d7a2c00caae6aa8480ddc4b2c50 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:25 +0800 Subject: [PATCH 394/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 6e888bb..6415240 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -25,7 +25,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl mvn-repo - https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo + https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo true @@ -51,7 +51,7 @@ Now you can use `jdbc:covenantsql:///` uri,repl ```gradle repositories { maven { - url 'https://raw.github.com/CovenantSQL/covenant-connector/mvn-repo' + url 'https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo' } } @@ -62,6 +62,6 @@ dependencies { ### Examples -1. [JDBC Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) -2. [MyBatis Example](https://github.com/CovenantSQL/covenant-connector/blob/master/covenantsql-java-connector/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +1. [JDBC Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) 3. [SpringBoot + MyBatis Project Example](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file From beb5d7d808c62c7db59f512524d068dd588a96c7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:27 +0800 Subject: [PATCH 395/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index d10956b..0ec29a1 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -62,7 +62,7 @@ If the problem persists please check out our GitHub page [submit issue](https:// ### TestNet -At present, we have released the test network v0.5.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". +At present, we have released the test network v0.7.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: From 683ba45fa2c38c54214b61d4fd63804813718179 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:33 +0800 Subject: [PATCH 396/421] New translations quandl.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/quandl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/quandl.md b/website/translated_docs/zh-CN/version-0.5.0/quandl.md index 246b98a..79f18df 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/quandl.md +++ b/website/translated_docs/zh-CN/version-0.5.0/quandl.md @@ -16,7 +16,7 @@ Quandl 是一个针对金融投资行业的大数据平台,其数据来源包 现在由于客户端兼容问题, 请直接使用我们的 HTTP 服务来对 Quandl 数据库进行 query,未来兼容现在的 `cql` 客户端后会第一时间更新此文档。 -具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) +具体通过 HTTP 服务来使用 CovenantSQL 请参考 [Python 驱动文档](https://github.com/CovenantSQL/cql-python-driver/blob/master/README.rst) 和 [NodeJS 驱动文档](https://github.com/CovenantSQL/node-covenantsql/blob/master/README.md) 所需参数: From adaead9a8af396eaa64bd4d9a9f64a8d5d257d99 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 19 Jun 2019 12:13:36 +0800 Subject: [PATCH 397/421] New translations guide-zh.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md index a5bdb48..3fb04dc 100644 --- a/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md +++ b/website/translated_docs/zh-CN/version-0.5.0/bck/guide-zh.md @@ -38,8 +38,8 @@ original_id: guide-zh ### 使用数据库驱动访问数据库 - [Go](./development-golang-client-zh.md) -- [Java](https://github.com/CovenantSQL/covenant-connector) -- [Python](https://github.com/CovenantSQL/python-driver) +- [Java](https://github.com/CovenantSQL/cql-java-driver) +- [Python](https://github.com/CovenantSQL/cql-python-driver) - [Javascript(开发中)](https://github.com/CovenantSQL/cql.js) ## 通过区块浏览器查看您的数据库操作记录 From 148979264d1f036351df4f3882175c3866f01f74 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 11 Jul 2019 08:24:45 +0800 Subject: [PATCH 398/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.7.0/quickstart.md | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.7.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.7.0/quickstart.md b/website/translated_docs/zh-CN/version-0.7.0/quickstart.md new file mode 100644 index 0000000..8dc8d9f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.7.0/quickstart.md @@ -0,0 +1,184 @@ +--- +id: version-0.7.0-quickstart +title: Quick Start +original_id: quickstart +--- + + +## CovenantSQL Client + +### Install + +Please choose the installation method according to the operating system platform you use: + +#### MacOS + +- 🍺 Homebrew users can just run: + + ```bash + brew install cql + ``` + +- non-Homebrew users can run: + + ```bash + sudo bash -c 'curl -L "https://mac.gridb.io/cql" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` + +#### Linux + +- Just run: + + ```bash + sudo bash -c 'curl -L "https://linux.gridb.io/cql" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` + +After the installation is complete, you can execute the following command to check whether the installation is successful. + +```bash +cql version +``` + +If you have any errors on the MacOS or Linux, you can try the following to fix it: + +```bash +sudo chmod a+x /usr/local/bin/cql* # Fix Permission +sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH +``` + +If the problem persists please check out our GitHub page [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D) + +### Utils + +| Tool | Introduction | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | + +> Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) + +### TestNet + +At present, we have released the test network v0.7.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". + +The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: + +```bash +mkdir -p ~/.cql/testnet-conf +curl -L https://git.io/fhFZe --output ~/.cql/testnet-conf/config.yaml +curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key +chmod 600 ~/.cql/testnet-conf/private.key +``` + +**TestNet Notes**: + +> The "public account" is public and only for testing. Please do not store your application information in the database created by the "public account". We will clean the database data from time to time. +> +> The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. + +## Create a testnet database + +```bash +cql create -config=~/.cql/testnet-conf/config.yaml \ + -db-node 1 -wait-tx-confirm +``` + +The command execution takes a little long time, and after about 30 seconds the console outputs something like below: + +> covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + +​ + +This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. + +> Command execution takes some time, and the general process is: +> +> 1. The "Block Producer" that received the request performs a match of Miner and database creation requests. +> 2. Database creation request is verified and confirmed at other "Block Producer" nodes +> 3. Eligible Miner on SQLChain receives database task +> 4. SQLChain Miners builds a database cluster with Kayak +> 5. All Miners are ready to wait for a database request + +## Access the testnet database + +```bash +cql console -config=~/.cql/testnet-conf/config.yaml \ + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. + +## SQLChain Explorer + +One feature of CovenantSQL is that its query records are **immutable and traceable**, you can query the operation of a database through \[Test Web Block Browser\] (https://explorer.dbhub.org/) recording. + +> The TestNet's SQLChain Explorer is currently open-access, and anyone who knows the database ID can manipulate your data using TestNet's public key. + +Please fill in your database ID in the upper right corner of the page. For example: `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872`. You can see information about all the data created using TestNet's Key: + +![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) + +> **If you want to create your own private database, you need to create a new public-private key pair from scratch, please refer to the following section.** + +## Create your own account + +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (default empty passphrase for private.key, you can add `-with-password` to set passphrase): + +```bash +cql generate +``` + +Output: + + Generating private key... + Please enter password for new private key + Generated private key. + Generating nonce... + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b + Generated nonce. + Generating config file... + Generated config. + + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + +This command will create a `.cql` directory for you in your `$HOME` directory: + +- `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; +- `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. + +It alse print your wallet address(also called the account address, CovenantSQL address): `Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95` + +You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). + +After up to 2 minutes while requested PTC, you can use the cql command line tool to check the balance: + +```bash +cql wallet +``` + +output: + + Particle balance is: 10000000 + Wave balance is: 0 + + +Congratulations, you have received our PTC stable currency, and you can start using CovenantSQL now. You can refer to [Golang uses CovenantSQL documentation](./driver_golang) for development. \ No newline at end of file From 0f627922bc1d89c2871a8b30b54869cea0155924 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 1 Aug 2019 11:34:10 +0800 Subject: [PATCH 399/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 366 ++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 website/translated_docs/zh-CN/deploy_miner.md diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md new file mode 100644 index 0000000..32693c0 --- /dev/null +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -0,0 +1,366 @@ +## 部署 CovenantSQL Miner 节点 + +文档对应版本: + + cql HEAD-f0e4e13d-2019080103005 + covenantsql/covenantsql 1601418d1aef + + +### 环境依赖 + +#### 机器配置 + +推荐运行服务在 AWS 的 `c5.2xlarge` 型机器或其他同等配置的机器上 (8 核, 16 GB 内存)。 + +另外建议单独挂载数据盘用于 DB 存储。 + +#### Docker + +CovenantSQL 使用 docker 来简化部署,可通过 Docker 的 [官方文档](https://docs.docker.com/install/) 来进行安装。 + +#### Docker 镜像 + +使用 docker 获取 CovenantSQL 的服务镜像以提供数据存储节点服务 + +```shell +docker pull covenantsql/covenantsql:latest +``` + +### 配置服务 + +#### 生成 Miner 配置文件 + +执行以下命令在当前目录中创建一个 config 目录,并生成 Miner 启动所需的配置文件 `config.yaml` 和 私钥 `private.key` + +> 请将命令中的 `miner_external_ip` 和 `miner_listen_port` 替换成实际 miner 运行时对外提供服务的 ip 或域名以及端口号;需要注意的是,之后使用者的命令行客户端或 Adapter 都将使用这个地址连接 Miner,请确保这个地址在使用者的机器上可以访问(没有被云平台或其他防火墙限制访问)。可以使用 telnet 或者 nc 的形式在 Miner 启动后检查服务的可用性 + +```shell +docker run -it --rm -v $(pwd)/config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate -miner ":" /app/config/ +``` + +命令将会生成一个 miner 的配置文件和私钥,并在命令行中输出 Miner 的节点 id、公钥 hex 和 钱包地址,例如: + +```shel +Generated private key. +Generating nonce... +INFO cpu: 8 +INFO position: 3, shift: 0x20, i: 7 +INFO position: 1, shift: 0x20, i: 3 +INFO position: 3, shift: 0x0, i: 6 +INFO position: 2, shift: 0x0, i: 4 +INFO position: 2, shift: 0x20, i: 5 +INFO position: 0, shift: 0x0, i: 0 +INFO position: 1, shift: 0x0, i: 2 +INFO position: 0, shift: 0x20, i: 1 +nonce: {{2677734 0 6632872946 0} 26 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d} +node id: 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d +Generated nonce. +Generating config file... +Generated config. + +Config file: /Users/xq262144/.cql/config.yaml +Private key file: /Users/xq262144/.cql/private.key +Public key's hex: 0338816967be3c24bd490f841de57f2c42daf024dd7f462305aab9a601c423ab8d +Wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 + +Any further command could costs PTC. +You can get some free PTC from: + https://testnet.covenantsql.io/wallet/eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +``` + +可以得到 miner 的钱包地址:`eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +#### 给 Miner 帐户充值 + +执行以下命令将会给 miner 的钱包地址转入 `10000000000` 个 `Particle` + +> 请将命令中的 `miner_wallet_address` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 `eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +```shell +mkdir -v ./testnet/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/private.key' -o ./testnet/private.key + +docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +命令将会从测试网帐户中划转金额给 miner 使用,miner 后续将会使用这笔费用作为押金来提供服务,将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io +INFO[0002] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 +INFO init config success path=/app/config/config.yaml + + +INFO wait transaction confirmation error="" tx_hash=09001b9904194400e85018984c5428616000669e5de0efac0dc65c72f11950a2 tx_state=Confirmed +INFO succeed in sending transaction to CovenantSQL +``` + +查询 miner 的账户余额以确定转账成功 + +```shell +docker run -it --rm -v $(pwd)/config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + wallet -config ./config/config.yaml +``` + +将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io +INFO[0002] Register self to blockproducer: 0000000000293f7216362791b6b1c9772184d6976cb34310c42547735410186c +INFO init config success path=/app/config/config.yaml + + +wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +Particle balance is: 100000000 +Wave balance is: 0 +``` + +Particle balance 这行输出中可以看到转账的金额,这样 miner 就可以提供服务了。 + +#### 添加 Miner 可服务的用户限制 + +在默认启动的情况下,Miner 是面向全网用户提供服务的。如果只希望给指定的 Miner 提供服务,需要在 Miner 上设置 TargetUsers 配置,并指定需要服务的用户的钱包地址。 + +修改 `miner` 的配置文件 `./config/config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改: + +```diff +--- old.yaml 2019-05-14 00:12:33.000000000 +0800 ++++ new.yaml 2019-05-14 00:12:19.000000000 +0800 +@@ -1,4 +1,5 @@ + Miner: + RootDir: './data' + MaxReqTimeGap: '5m' + ProvideServiceInterval: '10s' ++ TargetUsers: ['eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451'] +``` + +### 启动 Miner 服务 + +#### 创建 Container + +执行以下命令以创建 miner 的 + +> 请将下述命令中的 `miner_name` 替换成所需的 miner docker container 名用于管理;`data_disk_dir` 替换成用于存放 miner 数据的目录的绝对地址(推荐挂载一个盘用于提供服务);`miner_listen_port` 替换成miner 对外提供服务的端口号 + +```shell +docker create --name "" \ + --restart always \ + -v $(pwd)/config/:/app/config/ \ + -v ":/app/config/data/" \ + -e COVENANT_ROLE=miner \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e METRIC_WEB_ADDR=0.0.0.0:4665 \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +#### 启动 Miner + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker start "" +``` + +#### 检查 Miner 状态 + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker ps -a -f "name = " +docker logs --tail=10 -f "" +``` + +在单台或多台机器上重复上述步骤,启动多个实例,可以提供至多对应节点数量的 DB SideChain 服务。 + +#### 服务升级 + +执行以下命令更新镜像,然后重复 **创建 Container** 步骤 和 **启动 Miner** 步骤 + +```shell + docker pull covenantsql/covenantsql:latest +``` + +### 使用 + +#### 使用者账户和配置 + +使用 CovenantSQL 需要创建一个 DB 使用者的账户。这个账户必须与提供服务的 Miner 节点的账号不同,与此同时一个 Miner 账户也不能同时启动多个 Miner 服务,否则将会导致 Miner 或 DB 使用者的 Transaction 执行异常,用户不能正确创建 DB 或 Miner 不能正确上报使用者的费用信息等。 + +##### 生成使用者账户配置 + +执行如下命令将在 `./client_config` 目录下生成使用者账户的私钥和配置 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate /app/config/ +``` + +##### 向使用者账户中充值 + +类似向 Miner 账户充值,请执行如下命令: + +> 请将 `client_wallet_address` 替换为创建的使用者账号的钱包地址 + +```shell +docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +#### 创建 DB 和使用 + +由于需要在指定的 Miner 上创建 DB,需要在创建 DB 时指定提供服务的 Miner 列表 + +> `create` 命令接受一个 DB 实例的 json 描述;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`targetminers` 提供指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + create -config /app/config/config.yaml -wait-tx-confirm \ + '{"node": , "targetminers": ["", "" ...]}' +``` + +命令执行完成后将会有类似如下的输出: + +```shell +time="2019-05-07T03:41:03Z" level=info msg="Geting bp address from dns: bp04.testnet.gridb.io" +time="2019-05-07T03:41:05Z" level=info msg="Register self to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb" +level=info msg="init config success" path=/root/.cql/config.yaml +level=info msg="create database requested" +The newly created database is: "covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df" +The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console` + or any command, or be used in website like https://web.covenantsql.io +``` + +其中 `covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` 是数据库的连接串,可以在各类 SDK 或命令行工具中使用这个连接串访问数据库服务 + +#### 使用命令行工具连接数据库服务 + +可以是用 `cql` 工具提供的命令行功能访问数据库 + +> 将命令行中的 `dsn` 替换为上一步生成的数据库连接串 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + console -config /app/config/config.yaml "" +``` + +#### 启动 Adapter + +Java SDK 因为CovenantSQL 的 RPC 和网络连接协议的限制,不能直接访问 Miner 或 BlockProducer 节点,需要通过 Adapter 进行协议转换来访问。实际运行时,Java SDK/Adapter/Miner 是以如下图所示的形式交互的: + +```sequence +Java SDK ->Adapter: HTTP(s) Request +Adapter->Miner: ETLS RPC Request +Miner->Adapter: ETLS RPC Response +Adapter->Java SDK: HTTP(s) with JSON Response +``` + +可以通过如下命令启动 Adapter: + +> 请将命令中的 `adapter_name` 替换为所需的 adapter 的 docker container 名,将 `adapter_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=adapter \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动后如果 adapter 的 docker container 运行正常,将可以通过 `http://localhost:/` 访问 adapter 并获取到 adapter 的版本信息 + +#### 使用 Java SDK + +参考 [CovenantSQL Java SDK Github](https://github.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector) 和 [CovenantSQL Java SDK 使用文档](https://developers.covenantsql.io/docs/en/driver_java) 通过 Adapter 访问 + +> 上一步启动的 Adapter 是运行在非 TLS 模式下的开发权限服务,任何访问 Adapter 的人都将以 Adapter 启动的账户(也就是 `./client_config` 中的私钥与配置)的权限访问数据库服务。 +> +> 在 Java SDK 中设置配置 `ssl=false`(因为 Adapter 运行在了非 TLS 模式下提供的 http 服务),并以 `jdbc:covenantsql://:/` 即可访问(请将 `adapter_host` 替换为实际的运行机器的域名或 IP,将 `adapter_listen_port` 替换为上一步中的监听端口号,`database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`jdbc:covenantsql://127.0.0.1:11151/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df`) + +#### 获取 Miner 节点的 metric 信息 + +Miner 提供了 metric 数据的导出接口,可以通过下述命令访问和导出: + +> 讲命令中的 `miner_name` 替换为 启动 miner 的 container 名 + +```shell +miner_internal_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "" | head -1) +curl -s "http://${miner_internal_ip}:4665/debug/vars" +``` + +metric 信息对应表 + +| 字段名 | 含义 | +| ------------------------ | ----------------------------------------------------------------------- | +| service:miner:addr | 可访问的 Miner 的外部地址和端口(配置中的 ListenAddr) | +| service:miner:node | Miner 的 DHT 网络节点 ID | +| service:miner:wallet | Miner 的 钱包地址 | +| service:miner:disk:root | Miner 的 数据目录地址 | +| service:miner:disk:usage | Miner 使用的磁盘空间(KB) | +| service:miner:db:count | Miner 上正在提供服务的 ShardChain 数量 | +| service:miner:chain | Miner 上所有 ShardChain 统计信息,类型是一个 Map Map 的 key 是 ShardChain 的 DatabaseID | + + +针对每个 ShardChain 的统计信息,有如下字段 + +| 字段 | 含义 | +| -------------- | ------------------------------- | +| head:count | Chain 最新 Block 的编号(第几个块) | +| head:height | Chain 最新 Block 的 Epoch(第几个出块周期) | +| head:hash | Chain 最新 Block 的 Hash | +| head:timestamp | Chain 最新 Block 的产生时间(UTC) | +| requests:count | 最近 5 分钟统计范围内,1m 的请求数的平均值 | + + +#### 查看 Miner 节点上某个 DB Chain 的块信息 + +CovenantSQL 提供了一个方便的 Explorer 来展示数据库子链上的块信息,可以在通过如下命令启动 Explorer: + +> 其中替换 `explorer_name` 为想要运行 explorer 的 docker container 名,`explorer_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=observer \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_OBSERVER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动在浏览器里访问 `http://:/dbs/` + +> 其中 `explorer_external_address` 替换为物理机的外网 IP,`explorer_listen_port` 替换为上一步中指定的端口, `database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`http://miner_machine:11106/dbs/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` + +稍后等待块同步,即可在页面中看到历史产生的 Block,点击 Block 可以看到 Block 上承载的历史查询过的 Query 情况(如果没有自动出现块的信息,可以尝试手动刷新) + +> CovenantSQL 有严格的权限控制,需要对数据库有读权限的人才能使用 Explorer 看到这些 Query 历史和 Block 信息 \ No newline at end of file From def4b697b47a237210d429520cb5990c8fd23573 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 1 Aug 2019 11:44:37 +0800 Subject: [PATCH 400/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index 32693c0..8555dae 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -1,3 +1,9 @@ +* * * + +id: deploy_miner title: Deploy custom miner + +* * * + ## 部署 CovenantSQL Miner 节点 文档对应版本: From b75ab645d90f6523d1cb668bbdce04c6eb2c146c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 1 Aug 2019 11:54:20 +0800 Subject: [PATCH 401/421] New translations deploy_miner.md (Chinese Simplified) --- .../zh-CN/version-0.7.0/deploy_miner.md | 372 ++++++++++++++++++ 1 file changed, 372 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md diff --git a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md new file mode 100644 index 0000000..349891e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md @@ -0,0 +1,372 @@ +--- +id: version-0.7.0-deploy_miner +title: Deploy custom miner +original_id: deploy_miner +--- + +## 部署 CovenantSQL Miner 节点 + +文档对应版本: + + cql HEAD-f0e4e13d-2019080103005 + covenantsql/covenantsql 1601418d1aef + + +### 环境依赖 + +#### 机器配置 + +推荐运行服务在 AWS 的 `c5.2xlarge` 型机器或其他同等配置的机器上 (8 核, 16 GB 内存)。 + +另外建议单独挂载数据盘用于 DB 存储。 + +#### Docker + +CovenantSQL 使用 docker 来简化部署,可通过 Docker 的 [官方文档](https://docs.docker.com/install/) 来进行安装。 + +#### Docker 镜像 + +使用 docker 获取 CovenantSQL 的服务镜像以提供数据存储节点服务 + +```shell +docker pull covenantsql/covenantsql:latest +``` + +### 配置服务 + +#### 生成 Miner 配置文件 + +执行以下命令在当前目录中创建一个 config 目录,并生成 Miner 启动所需的配置文件 `config.yaml` 和 私钥 `private.key` + +> 请将命令中的 `miner_external_ip` 和 `miner_listen_port` 替换成实际 miner 运行时对外提供服务的 ip 或域名以及端口号;需要注意的是,之后使用者的命令行客户端或 Adapter 都将使用这个地址连接 Miner,请确保这个地址在使用者的机器上可以访问(没有被云平台或其他防火墙限制访问)。可以使用 telnet 或者 nc 的形式在 Miner 启动后检查服务的可用性 + +```shell +docker run -it --rm -v $(pwd)/config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate -miner ":" /app/config/ +``` + +命令将会生成一个 miner 的配置文件和私钥,并在命令行中输出 Miner 的节点 id、公钥 hex 和 钱包地址,例如: + +```shel +Generated private key. +Generating nonce... +INFO cpu: 8 +INFO position: 3, shift: 0x20, i: 7 +INFO position: 1, shift: 0x20, i: 3 +INFO position: 3, shift: 0x0, i: 6 +INFO position: 2, shift: 0x0, i: 4 +INFO position: 2, shift: 0x20, i: 5 +INFO position: 0, shift: 0x0, i: 0 +INFO position: 1, shift: 0x0, i: 2 +INFO position: 0, shift: 0x20, i: 1 +nonce: {{2677734 0 6632872946 0} 26 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d} +node id: 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d +Generated nonce. +Generating config file... +Generated config. + +Config file: /Users/xq262144/.cql/config.yaml +Private key file: /Users/xq262144/.cql/private.key +Public key's hex: 0338816967be3c24bd490f841de57f2c42daf024dd7f462305aab9a601c423ab8d +Wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 + +Any further command could costs PTC. +You can get some free PTC from: + https://testnet.covenantsql.io/wallet/eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +``` + +可以得到 miner 的钱包地址:`eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +#### 给 Miner 帐户充值 + +执行以下命令将会给 miner 的钱包地址转入 `10000000000` 个 `Particle` + +> 请将命令中的 `miner_wallet_address` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 `eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +```shell +mkdir -v ./testnet/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/private.key' -o ./testnet/private.key + +docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +命令将会从测试网帐户中划转金额给 miner 使用,miner 后续将会使用这笔费用作为押金来提供服务,将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io +INFO[0002] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 +INFO init config success path=/app/config/config.yaml + + +INFO wait transaction confirmation error="" tx_hash=09001b9904194400e85018984c5428616000669e5de0efac0dc65c72f11950a2 tx_state=Confirmed +INFO succeed in sending transaction to CovenantSQL +``` + +查询 miner 的账户余额以确定转账成功 + +```shell +docker run -it --rm -v $(pwd)/config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + wallet -config ./config/config.yaml +``` + +将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io +INFO[0002] Register self to blockproducer: 0000000000293f7216362791b6b1c9772184d6976cb34310c42547735410186c +INFO init config success path=/app/config/config.yaml + + +wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +Particle balance is: 100000000 +Wave balance is: 0 +``` + +Particle balance 这行输出中可以看到转账的金额,这样 miner 就可以提供服务了。 + +#### 添加 Miner 可服务的用户限制 + +在默认启动的情况下,Miner 是面向全网用户提供服务的。如果只希望给指定的 Miner 提供服务,需要在 Miner 上设置 TargetUsers 配置,并指定需要服务的用户的钱包地址。 + +修改 `miner` 的配置文件 `./config/config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改: + +```diff +--- old.yaml 2019-05-14 00:12:33.000000000 +0800 ++++ new.yaml 2019-05-14 00:12:19.000000000 +0800 +@@ -1,4 +1,5 @@ + Miner: + RootDir: './data' + MaxReqTimeGap: '5m' + ProvideServiceInterval: '10s' ++ TargetUsers: ['eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451'] +``` + +### 启动 Miner 服务 + +#### 创建 Container + +执行以下命令以创建 miner 的 + +> 请将下述命令中的 `miner_name` 替换成所需的 miner docker container 名用于管理;`data_disk_dir` 替换成用于存放 miner 数据的目录的绝对地址(推荐挂载一个盘用于提供服务);`miner_listen_port` 替换成miner 对外提供服务的端口号 + +```shell +docker create --name "" \ + --restart always \ + -v $(pwd)/config/:/app/config/ \ + -v ":/app/config/data/" \ + -e COVENANT_ROLE=miner \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e METRIC_WEB_ADDR=0.0.0.0:4665 \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +#### 启动 Miner + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker start "" +``` + +#### 检查 Miner 状态 + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker ps -a -f "name = " +docker logs --tail=10 -f "" +``` + +在单台或多台机器上重复上述步骤,启动多个实例,可以提供至多对应节点数量的 DB SideChain 服务。 + +#### 服务升级 + +执行以下命令更新镜像,然后重复 **创建 Container** 步骤 和 **启动 Miner** 步骤 + +```shell + docker pull covenantsql/covenantsql:latest +``` + +### 使用 + +#### 使用者账户和配置 + +使用 CovenantSQL 需要创建一个 DB 使用者的账户。这个账户必须与提供服务的 Miner 节点的账号不同,与此同时一个 Miner 账户也不能同时启动多个 Miner 服务,否则将会导致 Miner 或 DB 使用者的 Transaction 执行异常,用户不能正确创建 DB 或 Miner 不能正确上报使用者的费用信息等。 + +##### 生成使用者账户配置 + +执行如下命令将在 `./client_config` 目录下生成使用者账户的私钥和配置 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate /app/config/ +``` + +##### 向使用者账户中充值 + +类似向 Miner 账户充值,请执行如下命令: + +> 请将 `client_wallet_address` 替换为创建的使用者账号的钱包地址 + +```shell +docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +#### 创建 DB 和使用 + +由于需要在指定的 Miner 上创建 DB,需要在创建 DB 时指定提供服务的 Miner 列表 + +> `create` 命令接受一个 DB 实例的 json 描述;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`targetminers` 提供指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + create -config /app/config/config.yaml -wait-tx-confirm \ + '{"node": , "targetminers": ["", "" ...]}' +``` + +命令执行完成后将会有类似如下的输出: + +```shell +time="2019-05-07T03:41:03Z" level=info msg="Geting bp address from dns: bp04.testnet.gridb.io" +time="2019-05-07T03:41:05Z" level=info msg="Register self to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb" +level=info msg="init config success" path=/root/.cql/config.yaml +level=info msg="create database requested" +The newly created database is: "covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df" +The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console` + or any command, or be used in website like https://web.covenantsql.io +``` + +其中 `covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` 是数据库的连接串,可以在各类 SDK 或命令行工具中使用这个连接串访问数据库服务 + +#### 使用命令行工具连接数据库服务 + +可以是用 `cql` 工具提供的命令行功能访问数据库 + +> 将命令行中的 `dsn` 替换为上一步生成的数据库连接串 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + console -config /app/config/config.yaml "" +``` + +#### 启动 Adapter + +Java SDK 因为CovenantSQL 的 RPC 和网络连接协议的限制,不能直接访问 Miner 或 BlockProducer 节点,需要通过 Adapter 进行协议转换来访问。实际运行时,Java SDK/Adapter/Miner 是以如下图所示的形式交互的: + +```sequence +Java SDK ->Adapter: HTTP(s) Request +Adapter->Miner: ETLS RPC Request +Miner->Adapter: ETLS RPC Response +Adapter->Java SDK: HTTP(s) with JSON Response +``` + +可以通过如下命令启动 Adapter: + +> 请将命令中的 `adapter_name` 替换为所需的 adapter 的 docker container 名,将 `adapter_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=adapter \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动后如果 adapter 的 docker container 运行正常,将可以通过 `http://localhost:/` 访问 adapter 并获取到 adapter 的版本信息 + +#### 使用 Java SDK + +参考 [CovenantSQL Java SDK Github](https://github.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector) 和 [CovenantSQL Java SDK 使用文档](https://developers.covenantsql.io/docs/en/driver_java) 通过 Adapter 访问 + +> 上一步启动的 Adapter 是运行在非 TLS 模式下的开发权限服务,任何访问 Adapter 的人都将以 Adapter 启动的账户(也就是 `./client_config` 中的私钥与配置)的权限访问数据库服务。 +> +> 在 Java SDK 中设置配置 `ssl=false`(因为 Adapter 运行在了非 TLS 模式下提供的 http 服务),并以 `jdbc:covenantsql://:/` 即可访问(请将 `adapter_host` 替换为实际的运行机器的域名或 IP,将 `adapter_listen_port` 替换为上一步中的监听端口号,`database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`jdbc:covenantsql://127.0.0.1:11151/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df`) + +#### 获取 Miner 节点的 metric 信息 + +Miner 提供了 metric 数据的导出接口,可以通过下述命令访问和导出: + +> 讲命令中的 `miner_name` 替换为 启动 miner 的 container 名 + +```shell +miner_internal_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "" | head -1) +curl -s "http://${miner_internal_ip}:4665/debug/vars" +``` + +metric 信息对应表 + +| 字段名 | 含义 | +| ------------------------ | ----------------------------------------------------------------------- | +| service:miner:addr | 可访问的 Miner 的外部地址和端口(配置中的 ListenAddr) | +| service:miner:node | Miner 的 DHT 网络节点 ID | +| service:miner:wallet | Miner 的 钱包地址 | +| service:miner:disk:root | Miner 的 数据目录地址 | +| service:miner:disk:usage | Miner 使用的磁盘空间(KB) | +| service:miner:db:count | Miner 上正在提供服务的 ShardChain 数量 | +| service:miner:chain | Miner 上所有 ShardChain 统计信息,类型是一个 Map Map 的 key 是 ShardChain 的 DatabaseID | + + +针对每个 ShardChain 的统计信息,有如下字段 + +| 字段 | 含义 | +| -------------- | ------------------------------- | +| head:count | Chain 最新 Block 的编号(第几个块) | +| head:height | Chain 最新 Block 的 Epoch(第几个出块周期) | +| head:hash | Chain 最新 Block 的 Hash | +| head:timestamp | Chain 最新 Block 的产生时间(UTC) | +| requests:count | 最近 5 分钟统计范围内,1m 的请求数的平均值 | + + +#### 查看 Miner 节点上某个 DB Chain 的块信息 + +CovenantSQL 提供了一个方便的 Explorer 来展示数据库子链上的块信息,可以在通过如下命令启动 Explorer: + +> 其中替换 `explorer_name` 为想要运行 explorer 的 docker container 名,`explorer_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=observer \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_OBSERVER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动在浏览器里访问 `http://:/dbs/` + +> 其中 `explorer_external_address` 替换为物理机的外网 IP,`explorer_listen_port` 替换为上一步中指定的端口, `database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`http://miner_machine:11106/dbs/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` + +稍后等待块同步,即可在页面中看到历史产生的 Block,点击 Block 可以看到 Block 上承载的历史查询过的 Query 情况(如果没有自动出现块的信息,可以尝试手动刷新) + +> CovenantSQL 有严格的权限控制,需要对数据库有读权限的人才能使用 Explorer 看到这些 Query 历史和 Block 信息 \ No newline at end of file From 1193a9fbc06d65f0251834b3db61728403e8663b Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 1 Aug 2019 15:19:42 +0800 Subject: [PATCH 402/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index 8555dae..f0c8fc2 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -86,8 +86,8 @@ You can get some free PTC from: ```shell mkdir -v ./testnet/ -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/private.key' -o ./testnet/private.key +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./testnet/private.key docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ From add5595da76a0a584485c64ed1266949688df497 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 1 Aug 2019 15:19:45 +0800 Subject: [PATCH 403/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md index 349891e..90378f0 100644 --- a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md +++ b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md @@ -86,8 +86,8 @@ You can get some free PTC from: ```shell mkdir -v ./testnet/ -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql:latest/develop/conf/testnet/private.key' -o ./testnet/private.key +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./testnet/private.key docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ From 23e21f85ddeb552a6d0be538a4a34836f3ead7a7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 2 Aug 2019 19:39:05 +0800 Subject: [PATCH 404/421] New translations cql_db_access.md (Chinese Simplified) --- website/translated_docs/zh-CN/cql_db_access.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/website/translated_docs/zh-CN/cql_db_access.md b/website/translated_docs/zh-CN/cql_db_access.md index f7b18d0..7ef0d9d 100644 --- a/website/translated_docs/zh-CN/cql_db_access.md +++ b/website/translated_docs/zh-CN/cql_db_access.md @@ -64,7 +64,7 @@ The sub-command `console` also supports running `adapter` or `explorer` servers e.g. cql console covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c - There is also a -command param for SQL script, and a -file param for reading SQL in a file. + There is also a -command param for SQL script, and you can add "< file.sql" at end of command for executing a SQL file. If those params are set, it will run SQL script and exit without staying console mode. e.g. cql console -command "create table test1(test2 int);" covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c @@ -76,10 +76,6 @@ The sub-command `console` also supports running `adapter` or `explorer` servers Run only single command (SQL or usql internal command) and exit -explorer string Address serve a database chain explorer, e.g. :8546 - -file string - Execute commands from file and exit - -no-rc - Do not read start up file -out string Record stdout to file -single-transaction From 03cef6b712408505ae3df136cf26a8f834d96805 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Fri, 2 Aug 2019 19:47:17 +0800 Subject: [PATCH 405/421] New translations cql_db_access.md (Chinese Simplified) --- .../zh-CN/version-0.7.0/cql_db_access.md | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.7.0/cql_db_access.md diff --git a/website/translated_docs/zh-CN/version-0.7.0/cql_db_access.md b/website/translated_docs/zh-CN/version-0.7.0/cql_db_access.md new file mode 100644 index 0000000..31da3bc --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.7.0/cql_db_access.md @@ -0,0 +1,85 @@ +--- +id: version-0.7.0-cql_db_access +title: Accessing Database +original_id: cql_db_access +--- + +Once your database is successfully created, you can use the `console` sub-command to access it in an interactive console: + +```bash +cql console 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.cql/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-da3af8f6-20190515152207) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Or access as `account2` (Should been granted access permission and transfered deposit token to the database successfully in last section): + +```bash +cql console -config "account2/config.yaml" 'covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5' +``` + +Output: + + INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io + INFO[0010] init config success path=~/.config/cql/account2/config.yaml + INFO[0010] connecting to "covenantsql://4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5" + Connected with driver covenantsql (develop-da3af8f6-20190515152207) + Type "help" for help. + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +Here is an example of using the interactive console: + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> create table t1 (c1 int); + CREATE TABLE + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> insert into t1 values (1), (2), (3); + INSERT + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> select * from t1; + c1 + ---- + 1 + 2 + 3 + (3 rows) + + co:4bc27a06ae52a7b8b1747f3808dda786ddd188627bafe8e34a332626e7232ba5=> + + +## Sub-command `console` Complete Parameters + +The sub-command `console` also supports running `adapter` or `explorer` servers in the background. Check [Local Servers](#local-servers) for details. + + usage: cql console [common params] [Console params] dsn + + Console runs an interactive SQL console for CovenantSQL. + e.g. + cql console covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + There is also a -command param for SQL script, and you can add "< file.sql" at end of command for executing a SQL file. + If those params are set, it will run SQL script and exit without staying console mode. + e.g. + cql console -command "create table test1(test2 int);" covenantsql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c + + Console params: + -adapter string + Address to serve a database chain adapter, e.g. :7784 + -command string + Run only single command (SQL or usql internal command) and exit + -explorer string + Address serve a database chain explorer, e.g. :8546 + -out string + Record stdout to file + -single-transaction + Execute as a single transaction (if non-interactive) + -variable value + Set variable \ No newline at end of file From fd560a340a0f973017fb47538546aec54dcca2b6 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 17:56:33 +0800 Subject: [PATCH 406/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md index 90378f0..7d668d5 100644 --- a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md +++ b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md @@ -234,13 +234,13 @@ docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ 由于需要在指定的 Miner 上创建 DB,需要在创建 DB 时指定提供服务的 Miner 列表 -> `create` 命令接受一个 DB 实例的 json 描述;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`targetminers` 提供指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 +> `create` 命令接收一系列描述 DB 实例的参数,可以用 `cql help create` 查看详细参数;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`miner1_wallet_address, miner2_wallet_address` 等替换为指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 ```shell docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ create -config /app/config/config.yaml -wait-tx-confirm \ - '{"node": , "targetminers": ["", "" ...]}' + -db-node -db-target-miners ", , ..." ``` 命令执行完成后将会有类似如下的输出: From dbe00f63532ea9177a415239a232334e70999bdc Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 17:56:54 +0800 Subject: [PATCH 407/421] New translations arch.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/arch.md b/website/translated_docs/zh-CN/arch.md index cfbe9dd..e1540fa 100644 --- a/website/translated_docs/zh-CN/arch.md +++ b/website/translated_docs/zh-CN/arch.md @@ -24,7 +24,7 @@ CQL supports 2 kinds of consensus algorithm: 1. DPoS (Delegated Proof-of-Stake) is applied in `Eventually consistency mode` database and also `Layer 1 (Global Consensus Layer)` in BlockProducer. CQL miners pack all SQL queries and its signatures by the client into blocks thus form a blockchain. We named the algorithm [`Xenomint`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/xenomint). 2. BFT-Raft (Byzantine Fault-Toleranted Raft)bft-raft is applied in `Strong consistency mode` database. We named our implementation [`Kayak`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/kayak). The CQL miner leader does a `Two-Phase Commit` with `Kayak` to support `Transaction`.transaction -CQL database consistency mode and node count can be selected in database creation with command `cql create '{"UseEventualConsistency": true, "Node": 3}'` +CQL database consistency mode and node count can be selected in database creation with command `cql create -db-eventual-consistency -db-node 3` ## Comparison From d36c8f5b32143a8e8d36143585e634450a5ec33c Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 17:57:08 +0800 Subject: [PATCH 408/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index f0c8fc2..6728a9e 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -234,13 +234,13 @@ docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ 由于需要在指定的 Miner 上创建 DB,需要在创建 DB 时指定提供服务的 Miner 列表 -> `create` 命令接受一个 DB 实例的 json 描述;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`targetminers` 提供指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 +> `create` 命令接收一系列描述 DB 实例的参数,可以用 `cql help create` 查看详细参数;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`miner1_wallet_address, miner2_wallet_address` 等替换为指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 ```shell docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ create -config /app/config/config.yaml -wait-tx-confirm \ - '{"node": , "targetminers": ["", "" ...]}' + -db-node -db-target-miners ", , ..." ``` 命令执行完成后将会有类似如下的输出: From 81bb360e3bd2320f09dd478d4588d4e3406932e7 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 17:57:09 +0800 Subject: [PATCH 409/421] New translations arch_layers.md (Chinese Simplified) --- website/translated_docs/zh-CN/arch_layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/arch_layers.md b/website/translated_docs/zh-CN/arch_layers.md index 6be185d..4bc3fc3 100644 --- a/website/translated_docs/zh-CN/arch_layers.md +++ b/website/translated_docs/zh-CN/arch_layers.md @@ -10,7 +10,7 @@ CQL uses a layered architecture for database creation and operation. A typical d 1. Miner will automatically register with the MainChain after startup. The registration information includes: "Minimum acceptable Gas price", "System metrics", "External IP and port", etc. 2. Miner subscribes to and pays attention to information related to themselves through ChainBus; -3. The client runs `cql create '{"node":2}'` to send a signed database creation request to any BP (Block Producer) in the MainChain; +3. The client runs `cql create -db-node 2` to send a signed database creation request to any BP (Block Producer) in the MainChain; 4. The BP that received the request performs a match of Miner and database creation request in the process of producing the block (see: \[MainChain Produce Block\] (#mainchain-produce-block)); 5. Database creation requests and matching results are verified and confirmed at other BP nodes; 6. The Miner subscription receives the database task; From 4146363f0b0cecd4fed86c38fad52354d53ce242 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 18:26:01 +0800 Subject: [PATCH 410/421] New translations arch.md (Chinese Simplified) --- .../zh-CN/version-0.7.0/arch.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.7.0/arch.md diff --git a/website/translated_docs/zh-CN/version-0.7.0/arch.md b/website/translated_docs/zh-CN/version-0.7.0/arch.md new file mode 100644 index 0000000..cb39044 --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.7.0/arch.md @@ -0,0 +1,61 @@ +--- +id: version-0.7.0-arch +title: Architecture +original_id: arch +--- + +## 3 Layers Arch + +![CovenantSQL 3 Layer design](https://github.com/CovenantSQL/CovenantSQL/raw/ed2878359345cd86e4221f14cd59e4654361b64e/logo/arch.png) + +- Layer 1: **Global Consensus Layer** (the main chain, the middle ring in the architecture diagram): + - There will only be one main chain throughout the network. + - Mainly responsible for database Miner and the user’s contract matching, transaction settlement, anti-cheating, shard chain lock hash and other global consensus matters. +- Layer 2: **SQL Consensus Layer** (shard chain, rings on both sides): + - Each database will have its own separate shard chain. + - Mainly responsible for: the signature, delivery and consistency of the various Transactions of the database. The data history of the permanent traceability is mainly implemented here, and the hash lock is performed in the main chain. +- Layer 3: **Datastore Layer** (database engine with SQL-92 support): + - Each Database has its own independent distributed engine. + - Mainly responsible for: database storage & encryption, query processing & signature, efficient indexing. + +## Consensus Algorithm + +CQL supports 2 kinds of consensus algorithm: + +1. DPoS (Delegated Proof-of-Stake) is applied in `Eventually consistency mode` database and also `Layer 1 (Global Consensus Layer)` in BlockProducer. CQL miners pack all SQL queries and its signatures by the client into blocks thus form a blockchain. We named the algorithm [`Xenomint`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/xenomint). +2. BFT-Raft (Byzantine Fault-Toleranted Raft)bft-raft is applied in `Strong consistency mode` database. We named our implementation [`Kayak`](https://github.com/CovenantSQL/CovenantSQL/tree/develop/kayak). The CQL miner leader does a `Two-Phase Commit` with `Kayak` to support `Transaction`.transaction + +CQL database consistency mode and node count can be selected in database creation with command `cql create -db-eventual-consistency -db-node 3` + +## Comparison + +| | Ethereum | Hyperledger Fabric | Amazon QLDB | CovenantSQL | +| ---------------------------- | ----------------- | ---------------------- | ----------- | -------------------------------------------------------------------- | +| **Dev language** | Solidity, ewasm | Chaincode (Go, NodeJS) | ? | Python, Golang, Java, PHP, NodeJS, MatLab | +| **Dev Pattern** | Smart Contract | Chaincode | SQL | SQL | +| **Open Source** | Y | Y | N | Y | +| **Nodes for HA** | 3 | 15 | ? | 3 | +| **Column Level ACL** | N | Y | ? | Y | +| **Data Format** | File | Key-value | Document | Filefuse, Key-value, Structured | +| **Storage Encryption** | N | API | Y | Y | +| **Data Desensitization** | N | N | N | Y | +| **Multi-tenant** | DIY | DIY | N | Y | +| **Throughput (1s delay)** | 15~10 tx/s | 3500 tx/s | ? | 11065 tx/s (Eventually Consistency) +1866 tx/s (Strong Consistency) | +| **Consistency Delay** | 2~6 min | < 1 s | ? | < 10 ms | +| **Secure for Open Internet** | Y | N | Only in AWS | Y | +| **Consensus** | PoW + PoS(Casper) | CFT | ? | DPoS (Eventually Consistency) +BFT-Raft (Strong Consistency) | + + +### FootNotes + +- BFT-Raft: A CQL leader offline needs CQL Block Producer to decide whether to wait for leader online for data integrity or promote a follower node for availability. This part is still under construction and any advice is welcome. + +- Transaction: Talking about `ACID`, CQL has full "Consistency, Isolation, Durability" and a limited `Atomicity` support. That is even under strong consistency mode, CQL transaction is only supported on the leader node. If you want to do "read `v`, `v++`, write `v` back" parallelly and atomically, then the only way is "read `v` from the leader, `v++`, write `v` back to leader" + +- FUSE: CQL has a [simple FUSE](https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cql-fuse) support adopted from CockroachDB. The performance is not very ideal and still has some issues. But it can pass fio test like: + + ```bash + fio --debug=io --loops=1 --size=8m --filename=../mnt/fiotest.tmp --stonewall --direct=1 --name=Seqread --bs=128k --rw=read --name=Seqwrite --bs=128k --rw=write --name=4krandread --bs=4k --rw=randread --name=4krandwrite --bs=4k --rw=randwrite + ``` \ No newline at end of file From d2e86bb359b3006b41c717be801d111d2804f899 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Mon, 5 Aug 2019 18:26:02 +0800 Subject: [PATCH 411/421] New translations arch_layers.md (Chinese Simplified) --- .../zh-CN/version-0.7.0/arch_layers.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.7.0/arch_layers.md diff --git a/website/translated_docs/zh-CN/version-0.7.0/arch_layers.md b/website/translated_docs/zh-CN/version-0.7.0/arch_layers.md new file mode 100644 index 0000000..aae9a8f --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.7.0/arch_layers.md @@ -0,0 +1,30 @@ +--- +id: version-0.7.0-arch_layers +title: Blockchains +original_id: arch_layers +--- + + +## MainChain & SQLChain + +CQL uses a layered architecture for database creation and operation. A typical data creation process can be roughly as follows: + +1. Miner will automatically register with the MainChain after startup. The registration information includes: "Minimum acceptable Gas price", "System metrics", "External IP and port", etc. +2. Miner subscribes to and pays attention to information related to themselves through ChainBus; +3. The client runs `cql create -db-node 2` to send a signed database creation request to any BP (Block Producer) in the MainChain; +4. The BP that received the request performs a match of Miner and database creation request in the process of producing the block (see: \[MainChain Produce Block\] (#mainchain-produce-block)); +5. Database creation requests and matching results are verified and confirmed at other BP nodes; +6. The Miner subscription receives the database task; +7. Miners discover and connect with each other through Kayak to form a SQLChain database cluster; +8. All miners are ready to wait for a request; +9. Users can connect to the database and execute SQL through the `cql console` command. + +See the image below to view [large picture](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg): + +![2layers](https://cdn.jsdelivr.net/gh/CovenantSQL/docs@b7143254adb804dff0e3bc1f2f6ab11ad9cd44f5/website/static/img/2layers.svg) + +## MainChain Produce Block + +The complete main chain export process is complicated. Please refer to the numbers in the figure below for understanding. For the big picture, please click [here](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) + +![MainChain Produce Block](https://cdn.jsdelivr.net/gh/CovenantSQL/docs/website/static/img/produce-block.svg) \ No newline at end of file From 2cb6adc3f8cdeae3fffe690cbdec31eec84e1cc2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 6 Aug 2019 17:23:40 +0800 Subject: [PATCH 412/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md index 7d668d5..81f4f98 100644 --- a/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md +++ b/website/translated_docs/zh-CN/version-0.7.0/deploy_miner.md @@ -359,7 +359,7 @@ docker run -d -v $(pwd)/client_config/:/app/config/ \ --log-driver "json-file" \ --log-opt "max-size=1g" \ --log-opt "max-file=3" \ - -p ":4661" \ + -p ":" \ covenantsql/covenantsql:latest ``` From d84756679468ad75997a492a72b15ad5bcea12c2 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 6 Aug 2019 17:24:18 +0800 Subject: [PATCH 413/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index 6728a9e..aa3bd35 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -359,7 +359,7 @@ docker run -d -v $(pwd)/client_config/:/app/config/ \ --log-driver "json-file" \ --log-opt "max-size=1g" \ --log-opt "max-file=3" \ - -p ":4661" \ + -p ":" \ covenantsql/covenantsql:latest ``` From aa2088adc60d6ffbfa383e2c2e25844178a1c7c4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 7 Aug 2019 14:55:16 +0800 Subject: [PATCH 414/421] New translations quickstart.md (Chinese Simplified) --- website/translated_docs/zh-CN/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/translated_docs/zh-CN/quickstart.md b/website/translated_docs/zh-CN/quickstart.md index 0ec29a1..5e1d997 100644 --- a/website/translated_docs/zh-CN/quickstart.md +++ b/website/translated_docs/zh-CN/quickstart.md @@ -62,7 +62,7 @@ If the problem persists please check out our GitHub page [submit issue](https:// ### TestNet -At present, we have released the test network v0.7.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". +At present, we have released the test network v0.8.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: From 97e8be28e97a232e9984a2c36898b74dc231f31d Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 7 Aug 2019 15:09:24 +0800 Subject: [PATCH 415/421] New translations quickstart.md (Chinese Simplified) --- .../zh-CN/version-0.8.0/quickstart.md | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.8.0/quickstart.md diff --git a/website/translated_docs/zh-CN/version-0.8.0/quickstart.md b/website/translated_docs/zh-CN/version-0.8.0/quickstart.md new file mode 100644 index 0000000..560fd5a --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.8.0/quickstart.md @@ -0,0 +1,184 @@ +--- +id: version-0.8.0-quickstart +title: Quick Start +original_id: quickstart +--- + + +## CovenantSQL Client + +### Install + +Please choose the installation method according to the operating system platform you use: + +#### MacOS + +- 🍺 Homebrew users can just run: + + ```bash + brew install cql + ``` + +- non-Homebrew users can run: + + bash + sudo bash -c 'curl -L "https://mac.gridb.io/cql" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + +#### Linux + +- Just run: + + ```bash + sudo bash -c 'curl -L "https://linux.gridb.io/cql" | \ + tar xzv -C /usr/local/bin/ --strip-components=1' + ``` + +After the installation is complete, you can execute the following command to check whether the installation is successful. + +```bash +cql version +``` + +If you have any errors on the MacOS or Linux, you can try the following to fix it: + +```bash +sudo chmod a+x /usr/local/bin/cql* # Fix Permission +sudo ln -s /usr/local/bin/cql* /usr/bin/ # Fix if /usr/local/bin not in $PATH +``` + +If the problem persists please check out our GitHub page [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D) + +### Utils + +| Tool | Introduction | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| cql | CovenantSQL client, `cql console` command is similar to the `mysql` command and is used to manage the CQL databases, [More](./cql_intro) | +| cql-fuse | CovenantSQL's FUSE client, which can mount a CovenantSQL database as a file system | +| cql-minerd | CovenantSQL miner client, used to run the database to earn rewards, will open later | +| cqld | CovenantSQL main chain node, mainly run by CovenantLabs and partners in DPoS mode | + + +> Windows platform we will release later, if there is a need please [submit issue](https://github.com/CovenantSQL/CovenantSQL/issues/new?assignees=&labels=&template=feature_request.md&title=) + +### TestNet + +At present, we have released the test network v0.8.0 for everyone to verify and experience the principle. You can choose to quickly perform access testing using the "public account". + +The configuration file and private key of the "public account":[config.yaml](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/config.yaml)、[private.key](https://raw.githubusercontent.com/CovenantSQL/CovenantSQL/develop/conf/testnet/private.key) (empty password),or just run: + +```bash +mkdir -p ~/.cql/testnet-conf +curl -L https://git.io/fhFZe --output ~/.cql/testnet-conf/config.yaml +curl -L https://git.io/fhFZv --output ~/.cql/testnet-conf/private.key +chmod 600 ~/.cql/testnet-conf/private.key +``` + +**TestNet Notes**: + +> The "public account" is public and only for testing. Please do not store your application information in the database created by the "public account". We will clean the database data from time to time. +> +> The test network is temporarily composed of 3 Miners, so temporarily only supports `create 3` to create a database of 3 nodes. + +## Create a testnet database + +```bash +cql create -config=~/.cql/testnet-conf/config.yaml \ + -db-node 1 -wait-tx-confirm +``` + +The command execution takes a little long time, and after about 30 seconds the console outputs something like below: + +> covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 + +​ + +This means that you submitted the database(dsn) `covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872` creation request to the main chain and created the database to complete. + +> Command execution takes some time, and the general process is: +> +> 1. The "Block Producer" that received the request performs a match of Miner and database creation requests. +> 2. Database creation request is verified and confirmed at other "Block Producer" nodes +> 3. Eligible Miner on SQLChain receives database task +> 4. SQLChain Miners builds a database cluster with Kayak +> 5. All Miners are ready to wait for a database request + +## Access the testnet database + +```bash +cql console -config=~/.cql/testnet-conf/config.yaml \ + covenantsql://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872 +``` + +After connecting to the database, you can manipulate the database on CovenantSQL according to your habit of operating the database. For example, execute `CREATE TABLE` to create a table, `SELECT` query data, and so on. + +## SQLChain Explorer + +One feature of CovenantSQL is that its query records are **immutable and traceable**, you can query the operation of a database through \[Test Web Block Browser\] (https://explorer.dbhub.org/) recording. + +> The TestNet's SQLChain Explorer is currently open-access, and anyone who knows the database ID can manipulate your data using TestNet's public key. + +Please fill in your database ID in the upper right corner of the page. For example: `0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872`. You can see information about all the data created using TestNet's Key: + +![explorer](https://github.com/CovenantSQL/docs/raw/master/website/static/img/explorer.png) + +> **If you want to create your own private database, you need to create a new public-private key pair from scratch, please refer to the following section.** + +## Create your own account + +Our test network allows you to create your own account and create a database under your own account. Create an account with the following command (default empty passphrase for private.key, you can add `-with-password` to set passphrase): + +```bash +cql generate +``` + +Output: + + Generating private key... + Please enter password for new private key + Generated private key. + Generating nonce... + INFO cpu: 4 + INFO position: 2, shift: 0x0, i: 2 + INFO position: 0, shift: 0x0, i: 0 + INFO position: 3, shift: 0x0, i: 3 + INFO position: 1, shift: 0x0, i: 1 + nonce: {{973366 0 586194564 0} 26 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b} + node id: 0000002c32aa3ee39e4f461a5f5e7fda50859f597464d81c9618d443c476835b + Generated nonce. + Generating config file... + Generated config. + + Config file: ~/.cql/config.yaml + Private key file: ~/.cql/private.key + Public key's hex: 03f195dfe6237691e724bcf54359d76ef388b0996a3de94a7e782dac69192c96f0 + + Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + Any further command could costs PTC. + You can get some free PTC from: + https://testnet.covenantsql.io/wallet/dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95 + + +This command will create a `.cql` directory for you in your `$HOME` directory: + +- `~/.cql/private.key`: The generated private key is stored in the file by the master password encryption, and your account address needs to be created using this file; +- `~/.cql/config.yaml`: The generated configuration, cql can access the CovenantSQL TestNet with it. + +It alse print your wallet address(also called the account address, CovenantSQL address): `Wallet address: dbb7d1ee90452b8ee9cf514540b8d14fe5b7a750cc0c2f3824db6c8b284ada95` + +You can get the test PTC here with the wallet address obtained above: \[Request for PTC\] (https://testnet.covenantsql.io/). + +After up to 2 minutes while requested PTC, you can use the cql command line tool to check the balance: + +```bash +cql wallet +``` + +output: + + Particle balance is: 10000000 + Wave balance is: 0 + + +Congratulations, you have received our PTC stable currency, and you can start using CovenantSQL now. You can refer to [Golang uses CovenantSQL documentation](./driver_golang) for development. \ No newline at end of file From eb3f0969b204bee49aa872382357122cf4b137b4 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 7 Aug 2019 18:47:11 +0800 Subject: [PATCH 416/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 71 ++++++++++++++----- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index aa3bd35..f082d39 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -8,10 +8,20 @@ id: deploy_miner title: Deploy custom miner 文档对应版本: - cql HEAD-f0e4e13d-2019080103005 - covenantsql/covenantsql 1601418d1aef + covenantsql/covenantsql 84b7da393152 +本教程可以为中国测试网(testnet cn)或者国外测试网(testnet w) 部署 miner 节点,注意区分网络环境。 + +本教程在当前目录(`$PWD`) 会产生三个目录,分别是: + + miner_config: 您自己的 miner 节点配置 + super_client_config: 测试网超级客户端配置 + client_config: 您 miner 的使用者客户端配置 + + +各个命令都会使用上述配置之一,代表了命令的执行角色。 + ### 环境依赖 #### 机器配置 @@ -36,19 +46,24 @@ docker pull covenantsql/covenantsql:latest #### 生成 Miner 配置文件 -执行以下命令在当前目录中创建一个 config 目录,并生成 Miner 启动所需的配置文件 `config.yaml` 和 私钥 `private.key` +执行以下命令在当前目录中创建一个 miner_config 目录,并生成 Miner 启动所需的配置文件 `config.yaml` 和 私钥 `private.key` > 请将命令中的 `miner_external_ip` 和 `miner_listen_port` 替换成实际 miner 运行时对外提供服务的 ip 或域名以及端口号;需要注意的是,之后使用者的命令行客户端或 Adapter 都将使用这个地址连接 Miner,请确保这个地址在使用者的机器上可以访问(没有被云平台或其他防火墙限制访问)。可以使用 telnet 或者 nc 的形式在 Miner 启动后检查服务的可用性 ```shell -docker run -it --rm -v $(pwd)/config/:/app/config/ \ +mkdir -v ./miner_config + +docker run -it --rm -v $(pwd)/miner_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ generate -miner ":" /app/config/ ``` +> 如果需要生成国外区测试网配置,将上述命令的 `generate` 后面增加 `-testnet w` 参数。并且注意下述第一行输出会变成 `Generating testnet w config` + 命令将会生成一个 miner 的配置文件和私钥,并在命令行中输出 Miner 的节点 id、公钥 hex 和 钱包地址,例如: -```shel +```shell +Generating testnet cn config Generated private key. Generating nonce... INFO cpu: 8 @@ -66,8 +81,8 @@ Generated nonce. Generating config file... Generated config. -Config file: /Users/xq262144/.cql/config.yaml -Private key file: /Users/xq262144/.cql/private.key +Config file: /app/config/config.yaml +Private key file: /app/config/private.key Public key's hex: 0338816967be3c24bd490f841de57f2c42daf024dd7f462305aab9a601c423ab8d Wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 @@ -80,16 +95,30 @@ You can get some free PTC from: #### 给 Miner 帐户充值 +为了大家使用方便,我们创建了一个公共使用的超级客户端节点,拥有大量测试余额,首先需要下载这个超级客户端节点的配置: + +国内测试网: + +```shell +mkdir -v ./super_client_config/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./super_client_config/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./super_client_config/private.key +``` + +国外测试网: + +```shell +mkdir -v ./super_client_config/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/config.yaml' -o ./super_client_config/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/private.key' -o ./super_client_config/private.key +``` + 执行以下命令将会给 miner 的钱包地址转入 `10000000000` 个 `Particle` > 请将命令中的 `miner_wallet_address` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 `eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` ```shell -mkdir -v ./testnet/ -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml -curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./testnet/private.key - -docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ +docker run -it --rm -v $(pwd)/super_client_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ transfer -config /app/config/config.yaml \ -wait-tx-confirm -to-user "" \ @@ -112,7 +141,7 @@ INFO succeed in sending transaction to CovenantSQL 查询 miner 的账户余额以确定转账成功 ```shell -docker run -it --rm -v $(pwd)/config/:/app/config/ \ +docker run -it --rm -v $(pwd)/miner_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ wallet -config ./config/config.yaml ``` @@ -136,7 +165,7 @@ Particle balance 这行输出中可以看到转账的金额,这样 miner 就 在默认启动的情况下,Miner 是面向全网用户提供服务的。如果只希望给指定的 Miner 提供服务,需要在 Miner 上设置 TargetUsers 配置,并指定需要服务的用户的钱包地址。 -修改 `miner` 的配置文件 `./config/config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改: +修改 `miner` 的配置文件 `./miner_config/config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改: ```diff --- old.yaml 2019-05-14 00:12:33.000000000 +0800 @@ -160,7 +189,7 @@ Particle balance 这行输出中可以看到转账的金额,这样 miner 就 ```shell docker create --name "" \ --restart always \ - -v $(pwd)/config/:/app/config/ \ + -v $(pwd)/miner_config/:/app/config/ \ -v ":/app/config/data/" \ -e COVENANT_ROLE=miner \ -e COVENANT_CONF=/app/config/config.yaml \ @@ -168,7 +197,7 @@ docker create --name "" \ --log-driver "json-file" \ --log-opt "max-size=1g" \ --log-opt "max-file=3" \ - -p ":4661" \ + -p ":" \ covenantsql/covenantsql:latest ``` @@ -209,12 +238,18 @@ docker logs --tail=10 -f "" 执行如下命令将在 `./client_config` 目录下生成使用者账户的私钥和配置 +> 如果需要生成国外区测试网配置,将上述命令的 `generate` 后面增加 `-testnet w` 参数。并且注意第一行输出会变成 `Generating testnet w config` + ```shell +mkdir -v client_config + docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ generate /app/config/ ``` +命令最后一行会显示 wallet address,注意需要将此 wallet address 加入到 miner 的 `TargetUsers` 配置中,并重启 miner。 + ##### 向使用者账户中充值 类似向 Miner 账户充值,请执行如下命令: @@ -222,7 +257,7 @@ docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ > 请将 `client_wallet_address` 替换为创建的使用者账号的钱包地址 ```shell -docker run -it --rm -v $(pwd)/testnet/:/app/config/ \ +docker run -it --rm -v $(pwd)/super_client_config/:/app/config/ \ --entrypoint /app/cql covenantsql/covenantsql:latest -- \ transfer -config /app/config/config.yaml \ -wait-tx-confirm -to-user "" \ @@ -359,7 +394,7 @@ docker run -d -v $(pwd)/client_config/:/app/config/ \ --log-driver "json-file" \ --log-opt "max-size=1g" \ --log-opt "max-file=3" \ - -p ":" \ + -p ":4661" \ covenantsql/covenantsql:latest ``` From 7089b91b7df1a50b396be969b6c0fbae66bab002 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Wed, 7 Aug 2019 18:59:22 +0800 Subject: [PATCH 417/421] New translations deploy_miner.md (Chinese Simplified) --- .../zh-CN/version-0.8.0/deploy_miner.md | 407 ++++++++++++++++++ 1 file changed, 407 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md diff --git a/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md new file mode 100644 index 0000000..d9222df --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md @@ -0,0 +1,407 @@ +--- +id: version-0.8.0-deploy_miner +title: Deploy custom miner +original_id: deploy_miner +--- + +## 部署 CovenantSQL Miner 节点 + +文档对应版本: + + covenantsql/covenantsql 84b7da393152 + + +本教程可以为中国测试网(testnet cn)或者国外测试网(testnet w) 部署 miner 节点,注意区分网络环境。 + +本教程在当前目录(`$PWD`) 会产生三个目录,分别是: + + miner_config: 您自己的 miner 节点配置 + super_client_config: 测试网超级客户端配置 + client_config: 您 miner 的使用者客户端配置 + + +各个命令都会使用上述配置之一,代表了命令的执行角色。 + +### 环境依赖 + +#### 机器配置 + +推荐运行服务在 AWS 的 `c5.2xlarge` 型机器或其他同等配置的机器上 (8 核, 16 GB 内存)。 + +另外建议单独挂载数据盘用于 DB 存储。 + +#### Docker + +CovenantSQL 使用 docker 来简化部署,可通过 Docker 的 [官方文档](https://docs.docker.com/install/) 来进行安装。 + +#### Docker 镜像 + +使用 docker 获取 CovenantSQL 的服务镜像以提供数据存储节点服务 + +```shell +docker pull covenantsql/covenantsql:latest +``` + +### 配置服务 + +#### 生成 Miner 配置文件 + +执行以下命令在当前目录中创建一个 miner_config 目录,并生成 Miner 启动所需的配置文件 `config.yaml` 和 私钥 `private.key` + +> 请将命令中的 `miner_external_ip` 和 `miner_listen_port` 替换成实际 miner 运行时对外提供服务的 ip 或域名以及端口号;需要注意的是,之后使用者的命令行客户端或 Adapter 都将使用这个地址连接 Miner,请确保这个地址在使用者的机器上可以访问(没有被云平台或其他防火墙限制访问)。可以使用 telnet 或者 nc 的形式在 Miner 启动后检查服务的可用性 + +```shell +mkdir -v ./miner_config + +docker run -it --rm -v $(pwd)/miner_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate -miner ":" /app/config/ +``` + +> 如果需要生成国外区测试网配置,将上述命令的 `generate` 后面增加 `-testnet w` 参数。并且注意下述第一行输出会变成 `Generating testnet w config` + +命令将会生成一个 miner 的配置文件和私钥,并在命令行中输出 Miner 的节点 id、公钥 hex 和 钱包地址,例如: + +```shell +Generating testnet cn config +Generated private key. +Generating nonce... +INFO cpu: 8 +INFO position: 3, shift: 0x20, i: 7 +INFO position: 1, shift: 0x20, i: 3 +INFO position: 3, shift: 0x0, i: 6 +INFO position: 2, shift: 0x0, i: 4 +INFO position: 2, shift: 0x20, i: 5 +INFO position: 0, shift: 0x0, i: 0 +INFO position: 1, shift: 0x0, i: 2 +INFO position: 0, shift: 0x20, i: 1 +nonce: {{2677734 0 6632872946 0} 26 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d} +node id: 0000003e2c8d0b39711edf19ef266a44996b93f7f830149f5d01491a6b7da99d +Generated nonce. +Generating config file... +Generated config. + +Config file: /app/config/config.yaml +Private key file: /app/config/private.key +Public key's hex: 0338816967be3c24bd490f841de57f2c42daf024dd7f462305aab9a601c423ab8d +Wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 + +Any further command could costs PTC. +You can get some free PTC from: + https://testnet.covenantsql.io/wallet/eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +``` + +可以得到 miner 的钱包地址:`eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +#### 给 Miner 帐户充值 + +为了大家使用方便,我们创建了一个公共使用的超级客户端节点,拥有大量测试余额,首先需要下载这个超级客户端节点的配置: + +国内测试网: + +```shell +mkdir -v ./super_client_config/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./super_client_config/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./super_client_config/private.key +``` + +国外测试网: + +```shell +mkdir -v ./super_client_config/ +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/config.yaml' -o ./super_client_config/config.yaml +curl -kL -# 'https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/private.key' -o ./super_client_config/private.key +``` + +执行以下命令将会给 miner 的钱包地址转入 `10000000000` 个 `Particle` + +> 请将命令中的 `miner_wallet_address` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 `eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451` + +```shell +docker run -it --rm -v $(pwd)/super_client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +命令将会从测试网帐户中划转金额给 miner 使用,miner 后续将会使用这笔费用作为押金来提供服务,将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp04.testnet.gridb.io +INFO[0002] Register self to blockproducer: 00000000000589366268c274fdc11ec8bdb17e668d2f619555a2e9c1a29c91d8 +INFO init config success path=/app/config/config.yaml + + +INFO wait transaction confirmation error="" tx_hash=09001b9904194400e85018984c5428616000669e5de0efac0dc65c72f11950a2 tx_state=Confirmed +INFO succeed in sending transaction to CovenantSQL +``` + +查询 miner 的账户余额以确定转账成功 + +```shell +docker run -it --rm -v $(pwd)/miner_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + wallet -config ./config/config.yaml +``` + +将会得到类似以下的输出: + +```shell +INFO[0000] Geting bp address from dns: bp05.testnet.gridb.io +INFO[0002] Register self to blockproducer: 0000000000293f7216362791b6b1c9772184d6976cb34310c42547735410186c +INFO init config success path=/app/config/config.yaml + + +wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 +Particle balance is: 100000000 +Wave balance is: 0 +``` + +Particle balance 这行输出中可以看到转账的金额,这样 miner 就可以提供服务了。 + +#### 添加 Miner 可服务的用户限制 + +在默认启动的情况下,Miner 是面向全网用户提供服务的。如果只希望给指定的 Miner 提供服务,需要在 Miner 上设置 TargetUsers 配置,并指定需要服务的用户的钱包地址。 + +修改 `miner` 的配置文件 `./miner_config/config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改: + +```diff +--- old.yaml 2019-05-14 00:12:33.000000000 +0800 ++++ new.yaml 2019-05-14 00:12:19.000000000 +0800 +@@ -1,4 +1,5 @@ + Miner: + RootDir: './data' + MaxReqTimeGap: '5m' + ProvideServiceInterval: '10s' ++ TargetUsers: ['eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451'] +``` + +### 启动 Miner 服务 + +#### 创建 Container + +执行以下命令以创建 miner 的 + +> 请将下述命令中的 `miner_name` 替换成所需的 miner docker container 名用于管理;`data_disk_dir` 替换成用于存放 miner 数据的目录的绝对地址(推荐挂载一个盘用于提供服务);`miner_listen_port` 替换成miner 对外提供服务的端口号 + +```shell +docker create --name "" \ + --restart always \ + -v $(pwd)/miner_config/:/app/config/ \ + -v ":/app/config/data/" \ + -e COVENANT_ROLE=miner \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e METRIC_WEB_ADDR=0.0.0.0:4665 \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":" \ + covenantsql/covenantsql:latest +``` + +#### 启动 Miner + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker start "" +``` + +#### 检查 Miner 状态 + +> 同样,请将 `miner_name` 替换为实际使用的 miner container 名 + +```shell +docker ps -a -f "name = " +docker logs --tail=10 -f "" +``` + +在单台或多台机器上重复上述步骤,启动多个实例,可以提供至多对应节点数量的 DB SideChain 服务。 + +#### 服务升级 + +执行以下命令更新镜像,然后重复 **创建 Container** 步骤 和 **启动 Miner** 步骤 + +```shell + docker pull covenantsql/covenantsql:latest +``` + +### 使用 + +#### 使用者账户和配置 + +使用 CovenantSQL 需要创建一个 DB 使用者的账户。这个账户必须与提供服务的 Miner 节点的账号不同,与此同时一个 Miner 账户也不能同时启动多个 Miner 服务,否则将会导致 Miner 或 DB 使用者的 Transaction 执行异常,用户不能正确创建 DB 或 Miner 不能正确上报使用者的费用信息等。 + +##### 生成使用者账户配置 + +执行如下命令将在 `./client_config` 目录下生成使用者账户的私钥和配置 + +> 如果需要生成国外区测试网配置,将上述命令的 `generate` 后面增加 `-testnet w` 参数。并且注意第一行输出会变成 `Generating testnet w config` + +```shell +mkdir -v client_config + +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + generate /app/config/ +``` + +命令最后一行会显示 wallet address,注意需要将此 wallet address 加入到 miner 的 `TargetUsers` 配置中,并重启 miner。 + +##### 向使用者账户中充值 + +类似向 Miner 账户充值,请执行如下命令: + +> 请将 `client_wallet_address` 替换为创建的使用者账号的钱包地址 + +```shell +docker run -it --rm -v $(pwd)/super_client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + transfer -config /app/config/config.yaml \ + -wait-tx-confirm -to-user "" \ + -amount 10000000000 \ + -token Particle +``` + +#### 创建 DB 和使用 + +由于需要在指定的 Miner 上创建 DB,需要在创建 DB 时指定提供服务的 Miner 列表 + +> `create` 命令接收一系列描述 DB 实例的参数,可以用 `cql help create` 查看详细参数;将 `node_count` 替换为所需的节点数量,例如 1 代表创建一个节点的 DB SideChain;`miner1_wallet_address, miner2_wallet_address` 等替换为指定 miner 的钱包地址列表;另外需要格外注意的时,所需创建的 DB SideChain 的节点数量需要小于或等于提供的指定 miner 数量,否则 CovenantSQL 会在指定 miner 之外的公用 miner 中随机分配节点以满足用户所需节点数量要求。 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + create -config /app/config/config.yaml -wait-tx-confirm \ + -db-node -db-target-miners ", , ..." +``` + +命令执行完成后将会有类似如下的输出: + +```shell +time="2019-05-07T03:41:03Z" level=info msg="Geting bp address from dns: bp04.testnet.gridb.io" +time="2019-05-07T03:41:05Z" level=info msg="Register self to blockproducer: 00000000003b2bd120a7d07f248b181fc794ba8b278f07f9a780e61eb77f6abb" +level=info msg="init config success" path=/root/.cql/config.yaml +level=info msg="create database requested" +The newly created database is: "covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df" +The connecting string beginning with 'covenantsql://' could be used as a dsn for `cql console` + or any command, or be used in website like https://web.covenantsql.io +``` + +其中 `covenantsql://163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` 是数据库的连接串,可以在各类 SDK 或命令行工具中使用这个连接串访问数据库服务 + +#### 使用命令行工具连接数据库服务 + +可以是用 `cql` 工具提供的命令行功能访问数据库 + +> 将命令行中的 `dsn` 替换为上一步生成的数据库连接串 + +```shell +docker run -it --rm -v $(pwd)/client_config/:/app/config/ \ + --entrypoint /app/cql covenantsql/covenantsql:latest -- \ + console -config /app/config/config.yaml "" +``` + +#### 启动 Adapter + +Java SDK 因为CovenantSQL 的 RPC 和网络连接协议的限制,不能直接访问 Miner 或 BlockProducer 节点,需要通过 Adapter 进行协议转换来访问。实际运行时,Java SDK/Adapter/Miner 是以如下图所示的形式交互的: + +```sequence +Java SDK ->Adapter: HTTP(s) Request +Adapter->Miner: ETLS RPC Request +Miner->Adapter: ETLS RPC Response +Adapter->Java SDK: HTTP(s) with JSON Response +``` + +可以通过如下命令启动 Adapter: + +> 请将命令中的 `adapter_name` 替换为所需的 adapter 的 docker container 名,将 `adapter_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=adapter \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动后如果 adapter 的 docker container 运行正常,将可以通过 `http://localhost:/` 访问 adapter 并获取到 adapter 的版本信息 + +#### 使用 Java SDK + +参考 [CovenantSQL Java SDK Github](https://github.com/CovenantSQL/covenant-connector/tree/master/covenantsql-java-connector) 和 [CovenantSQL Java SDK 使用文档](https://developers.covenantsql.io/docs/en/driver_java) 通过 Adapter 访问 + +> 上一步启动的 Adapter 是运行在非 TLS 模式下的开发权限服务,任何访问 Adapter 的人都将以 Adapter 启动的账户(也就是 `./client_config` 中的私钥与配置)的权限访问数据库服务。 +> +> 在 Java SDK 中设置配置 `ssl=false`(因为 Adapter 运行在了非 TLS 模式下提供的 http 服务),并以 `jdbc:covenantsql://:/` 即可访问(请将 `adapter_host` 替换为实际的运行机器的域名或 IP,将 `adapter_listen_port` 替换为上一步中的监听端口号,`database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`jdbc:covenantsql://127.0.0.1:11151/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df`) + +#### 获取 Miner 节点的 metric 信息 + +Miner 提供了 metric 数据的导出接口,可以通过下述命令访问和导出: + +> 讲命令中的 `miner_name` 替换为 启动 miner 的 container 名 + +```shell +miner_internal_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "" | head -1) +curl -s "http://${miner_internal_ip}:4665/debug/vars" +``` + +metric 信息对应表 + +| 字段名 | 含义 | +| ------------------------ | ----------------------------------------------------------------------- | +| service:miner:addr | 可访问的 Miner 的外部地址和端口(配置中的 ListenAddr) | +| service:miner:node | Miner 的 DHT 网络节点 ID | +| service:miner:wallet | Miner 的 钱包地址 | +| service:miner:disk:root | Miner 的 数据目录地址 | +| service:miner:disk:usage | Miner 使用的磁盘空间(KB) | +| service:miner:db:count | Miner 上正在提供服务的 ShardChain 数量 | +| service:miner:chain | Miner 上所有 ShardChain 统计信息,类型是一个 Map Map 的 key 是 ShardChain 的 DatabaseID | + + +针对每个 ShardChain 的统计信息,有如下字段 + +| 字段 | 含义 | +| -------------- | ------------------------------- | +| head:count | Chain 最新 Block 的编号(第几个块) | +| head:height | Chain 最新 Block 的 Epoch(第几个出块周期) | +| head:hash | Chain 最新 Block 的 Hash | +| head:timestamp | Chain 最新 Block 的产生时间(UTC) | +| requests:count | 最近 5 分钟统计范围内,1m 的请求数的平均值 | + + +#### 查看 Miner 节点上某个 DB Chain 的块信息 + +CovenantSQL 提供了一个方便的 Explorer 来展示数据库子链上的块信息,可以在通过如下命令启动 Explorer: + +> 其中替换 `explorer_name` 为想要运行 explorer 的 docker container 名,`explorer_listen_port` 替换为所需暴露在物理机器上的端口号 + +```shell +docker run -d -v $(pwd)/client_config/:/app/config/ \ + -e COVENANT_ROLE=observer \ + -e COVENANT_CONF=/app/config/config.yaml \ + -e COVENANTSQL_OBSERVER_ADDR=0.0.0.0:4661 \ + --name "" \ + --restart always \ + --log-driver "json-file" \ + --log-opt "max-size=1g" \ + --log-opt "max-file=3" \ + -p ":4661" \ + covenantsql/covenantsql:latest +``` + +启动在浏览器里访问 `http://:/dbs/` + +> 其中 `explorer_external_address` 替换为物理机的外网 IP,`explorer_listen_port` 替换为上一步中指定的端口, `database_id` 替换为创建 DB 后返回的 `dsn` 中去除 `covenantsql://` scheme 的 hex 串部分,例如:`http://miner_machine:11106/dbs/163193957a22fccf165ad754ee514f13972c0eadee6455203b17b7bba76028df` + +稍后等待块同步,即可在页面中看到历史产生的 Block,点击 Block 可以看到 Block 上承载的历史查询过的 Query 情况(如果没有自动出现块的信息,可以尝试手动刷新) + +> CovenantSQL 有严格的权限控制,需要对数据库有读权限的人才能使用 Explorer 看到这些 Query 历史和 Block 信息 \ No newline at end of file From 10d67b692a08198c7eaccf75dac38617f5882261 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 8 Aug 2019 12:25:23 +0800 Subject: [PATCH 418/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/deploy_miner.md b/website/translated_docs/zh-CN/deploy_miner.md index f082d39..7ba546d 100644 --- a/website/translated_docs/zh-CN/deploy_miner.md +++ b/website/translated_docs/zh-CN/deploy_miner.md @@ -8,7 +8,7 @@ id: deploy_miner title: Deploy custom miner 文档对应版本: - covenantsql/covenantsql 84b7da393152 + covenantsql/covenantsql e87bfd412293 本教程可以为中国测试网(testnet cn)或者国外测试网(testnet w) 部署 miner 节点,注意区分网络环境。 @@ -386,7 +386,7 @@ CovenantSQL 提供了一个方便的 Explorer 来展示数据库子链上的块 ```shell docker run -d -v $(pwd)/client_config/:/app/config/ \ - -e COVENANT_ROLE=observer \ + -e COVENANT_ROLE=explorer \ -e COVENANT_CONF=/app/config/config.yaml \ -e COVENANTSQL_OBSERVER_ADDR=0.0.0.0:4661 \ --name "" \ From 05b6389e2a4a8b86242ce9b3567e5aa77dbb2506 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Thu, 8 Aug 2019 12:25:24 +0800 Subject: [PATCH 419/421] New translations deploy_miner.md (Chinese Simplified) --- website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md b/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md index d9222df..2cf6180 100644 --- a/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md +++ b/website/translated_docs/zh-CN/version-0.8.0/deploy_miner.md @@ -8,7 +8,7 @@ original_id: deploy_miner 文档对应版本: - covenantsql/covenantsql 84b7da393152 + covenantsql/covenantsql e87bfd412293 本教程可以为中国测试网(testnet cn)或者国外测试网(testnet w) 部署 miner 节点,注意区分网络环境。 @@ -386,7 +386,7 @@ CovenantSQL 提供了一个方便的 Explorer 来展示数据库子链上的块 ```shell docker run -d -v $(pwd)/client_config/:/app/config/ \ - -e COVENANT_ROLE=observer \ + -e COVENANT_ROLE=explorer \ -e COVENANT_CONF=/app/config/config.yaml \ -e COVENANTSQL_OBSERVER_ADDR=0.0.0.0:4661 \ --name "" \ From ffdf142443f0eba9a41fbc3bd5a59d96a42a2f82 Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 27 Aug 2019 14:50:12 +0800 Subject: [PATCH 420/421] New translations driver_java.md (Chinese Simplified) --- website/translated_docs/zh-CN/driver_java.md | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/website/translated_docs/zh-CN/driver_java.md b/website/translated_docs/zh-CN/driver_java.md index 6415240..b96902d 100644 --- a/website/translated_docs/zh-CN/driver_java.md +++ b/website/translated_docs/zh-CN/driver_java.md @@ -21,27 +21,12 @@ Now you can use `jdbc:covenantsql:///` uri,repl #### Maven -```xml - - - mvn-repo - https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo - - true - - - true - - - -``` - ```xml io.covenantsql - covenantsql-java-connector - 1.0-SNAPSHOT + cql-java-connector + 1.0.1 ``` From ab4c9edec4a267cadf53d72abc67492e83947e5a Mon Sep 17 00:00:00 2001 From: foreseaz Date: Tue, 27 Aug 2019 15:07:27 +0800 Subject: [PATCH 421/421] New translations driver_java.md (Chinese Simplified) --- .../zh-CN/version-0.8.0/driver_java.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 website/translated_docs/zh-CN/version-0.8.0/driver_java.md diff --git a/website/translated_docs/zh-CN/version-0.8.0/driver_java.md b/website/translated_docs/zh-CN/version-0.8.0/driver_java.md new file mode 100644 index 0000000..95df21e --- /dev/null +++ b/website/translated_docs/zh-CN/version-0.8.0/driver_java.md @@ -0,0 +1,53 @@ +--- +id: version-0.8.0-driver_java +title: Java +original_id: driver_java +--- + +## Use Java to access CovenantSQL + +`CovenantSQL` provides `Java SDK` to access database instance through [`Adapter`](./adapter) service. + +`Java SDK` is compatible with `JDBC4` specifications,and popular `ORM` like `MyBatis` is supported through JDBC interface. + +### Compatibility + +`Java SDK` requires `Java 1.7+`. + +### Installation and quick start + +Before using `Java SDK`, an adapter tool deployment is required, please see [Deploy Adapter Service](./adapter). + +Now you can use `jdbc:covenantsql:///` uri,replacing `adapter_endpoint` with adapter listen address,`database_id` with database id。 + +#### Maven + +```xml + + + io.covenantsql + cql-java-connector + 1.0.1 + + +``` + +#### Gradle + +```gradle +repositories { + maven { + url 'https://raw.github.com/CovenantSQL/cql-java-driver/mvn-repo' + } +} + +dependencies { + compile 'io.covenantsql:covenantsql-java-connector:1.0-SNAPSHOT' +} +``` + +### Examples + +1. [JDBC Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/jdbc/Example.java) +2. [MyBatis Example](https://github.com/CovenantSQL/cql-java-driver/blob/master/example/src/main/java/io/covenantsql/connector/example/mybatis/Example.java) +3. [SpringBoot + MyBatis Project Example](https://github.com/CovenantSQL/covenantsql-mybatis-spring-boot-jpetstore) \ No newline at end of file