|
| 1 | +--- |
| 2 | +id: version-0.6.0-adapter |
| 3 | +title: Adapter |
| 4 | +original_id: adapter |
| 5 | +--- |
| 6 | + |
| 7 | +# Use Adapter to access CovenantSQL |
| 8 | + |
| 9 | +`CovenantSQL` provides an HTTP/HTTPS adapter service. Developers could access CovenantSQL like a cloud database by using HTTP RESTful requests. |
| 10 | + |
| 11 | +## How to use |
| 12 | + |
| 13 | +First, [Install docker](https://docs.docker.com/install/). |
| 14 | + |
| 15 | +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) |
| 16 | + |
| 17 | +### Start adapter using docker |
| 18 | + |
| 19 | +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`. |
| 20 | + |
| 21 | +```bash |
| 22 | +export adapter_addr=0.0.0.0:11105 |
| 23 | +docker rm -f cql-adapter |
| 24 | +docker run -itd \ |
| 25 | + --env COVENANT_ROLE=adapter --env COVENANT_CONF=/app/config.yaml \ |
| 26 | + --env COVENANTSQL_ADAPTER_ADDR=0.0.0.0:4661 \ |
| 27 | + -v ~/.cql/config.yaml:/app/config.yaml \ |
| 28 | + -v ~/.cql/private.key:/app/private.key \ |
| 29 | + --name cql-adapter -p $adapter_addr:4661 \ |
| 30 | + covenantsql/covenantsql:testnet |
| 31 | +``` |
| 32 | + |
| 33 | +### Create database |
| 34 | + |
| 35 | +Create new database using `cql create` command and provide database instance requirements. |
| 36 | + |
| 37 | +For example, create a single node database instance: |
| 38 | + |
| 39 | +```bash |
| 40 | +docker run -it --rm \ |
| 41 | + -v ~/.cql/config.yaml:/app/config.yaml \ |
| 42 | + -v ~/.cql/private.key:/app/private.key \ |
| 43 | + --entrypoint /app/cql covenantsql/covenantsql:testnet \ |
| 44 | + create -config /app/config.yaml -wait-tx-confirm -db-node 1 |
| 45 | +``` |
| 46 | + |
| 47 | +This command would produce a database connection string (DSN) similar to following example. |
| 48 | + |
| 49 | +```bash |
| 50 | +covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4 |
| 51 | +``` |
| 52 | + |
| 53 | +Use DSN to access CovenantSQL using various drivers. |
| 54 | + |
| 55 | +## Drivers |
| 56 | + |
| 57 | +1. [Golang](./driver_golang) |
| 58 | +2. [Java](./driver_java) |
| 59 | +3. [Python](./driver_python) |
| 60 | +4. [NodeJS](./driver_js) |
0 commit comments