File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ Documentation
53
53
54
54
Documentation is available online: http://developers.covenantsql.io/
55
55
56
- Key file and database_id can get from: http://developers.covenantsql.io/docs/quickstart
56
+ Key file and dsn can get from: http://developers.covenantsql.io/docs/quickstart
57
57
58
58
For support, please fire a issue at `Github
59
59
<https://github.com/CovenantSQL/CovenantSQL/issues/new> `_.
@@ -76,14 +76,13 @@ The following examples make use of a simple table
76
76
77
77
import pycovenantsql
78
78
79
- # user key file location
80
- key = ' /path/to/private.key'
81
79
82
- # Connect to the database
83
- connection = pycovenantsql.connect(host = ' localhost' ,
80
+ # Connect to the database with dsn
81
+ # host and port are your local CovenantSQL Adapter server
82
+ connection = pycovenantsql.connect(
83
+ dsn = ' covenantsql://your_database_id' ,
84
+ host = ' localhost' ,
84
85
port = 11108 ,
85
- key = key,
86
- database = ' database_id'
87
86
)
88
87
89
88
try :
Original file line number Diff line number Diff line change 6
6
7
7
print (pycovenantsql .get_client_info ())
8
8
9
- conn = pycovenantsql .connect (dsn = 'covenant ://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872' ,
10
- host = "adp00.cn.gridb.io" , port = 7784 , database = '0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872' )
9
+ conn = pycovenantsql .connect (dsn = 'covenantsql ://0a10b74439f2376d828c9a70fd538dac4b69e0f4065424feebc0f5dbc8b34872' ,
10
+ host = "adp00.cn.gridb.io" , port = 7784 )
11
11
12
12
cur = conn .cursor ()
13
13
print (cur .description )
Original file line number Diff line number Diff line change 1
1
import sys
2
2
import os
3
3
import requests
4
+ from urllib .parse import urlparse
4
5
from . import err
5
6
from .cursors import Cursor
6
7
from .optionfile import Parser
@@ -83,6 +84,12 @@ def _config(key, arg):
83
84
self .port = port or 11108
84
85
self .key = key
85
86
self .database = database
87
+ if self .dsn :
88
+ u = urlparse (self .dsn )
89
+ scheme = u .scheme .lower ()
90
+ if scheme == "covenantsql" or scheme == "cql" :
91
+ if u .hostname :
92
+ self .database = u .hostname
86
93
if https_pem :
87
94
self ._cert = (https_pem , self .key )
88
95
elif self .key :
You can’t perform that action at this time.
0 commit comments