Skip to content

Commit 7b293dd

Browse files
committed
Add doc string for chdb.connect
1 parent 4a61bbe commit 7b293dd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

chdb/state/sqlitelike.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,32 @@ def __next__(self) -> tuple:
101101

102102

103103
def connect(connection_string: str = ":memory:") -> Connection:
104+
"""
105+
Create a connection to chDB backgroud server.
106+
Only one open connection is allowed per process. Use `close` to close the connection.
107+
If called with the same connection string, the same connection object will be returned.
108+
You can use the connection object to create cursor object. `cursor` method will return a cursor object.
109+
110+
Args:
111+
connection_string (str, optional): Connection string. Defaults to ":memory:".
112+
Aslo support file path like:
113+
- ":memory:" (for in-memory database)
114+
- "test.db" (for relative path)
115+
- "file:test.db" (same as above)
116+
- "/path/to/test.db" (for absolute path)
117+
- "file:/path/to/test.db" (same as above)
118+
- "file:test.db?param1=value1&param2=value2" (for relative path with query params)
119+
- "///path/to/test.db?param1=value1&param2=value2" (for absolute path)
120+
121+
Connection string args handling:
122+
Connection string can contain query params like "file:test.db?param1=value1&param2=value2"
123+
"param1=value1" will be passed to ClickHouse engine as start up args.
124+
125+
For more details, see `clickhouse local --help --verbose`
126+
Some special args handling:
127+
- "mode=ro" would be "--readonly=1" for clickhouse (read-only mode)
128+
129+
Returns:
130+
Connection: Connection object
131+
"""
104132
return Connection(connection_string)

0 commit comments

Comments
 (0)