Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit 6ba2c54

Browse files
author
root
committed
2 parents 9065665 + 901cdef commit 6ba2c54

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
[![.github/workflows/release.yml](https://github.com/chdb-io/chdb-server/actions/workflows/release.yml/badge.svg)](https://github.com/chdb-io/chdb-server/actions/workflows/release.yml)
66

77
# chdb-server
8-
[chDB](https://github.com/auxten/chdb) + basic API server in a docker container, for fast testing and feature validation.
9-
10-
> chdb-server queries default to stateless. Stateful sessions can be generated with Basic HTTP Auth.
11-
12-
![image](https://github.com/chdb-io/chdb-server/assets/1423657/dee938a2-ec2a-4b4a-87a9-458a6db791a0)
13-
14-
15-
16-
### [Play with Public Demo](https://chdb.fly.dev/)
8+
[chDB](https://github.com/auxten/chdb) + basic HTTP/s API server in a docker container, _pretending to be ClickHouse_
179

10+
### [Public Demo](https://chdb.fly.dev/)
1811

1912
<br>
2013

@@ -25,13 +18,21 @@
2518
<br><br>
2619

2720

28-
### Docker Demo
21+
### Docker Setup
2922
```
3023
docker run --rm -p 8123:8123 ghcr.io/chdb-io/chdb-server:latest
3124
```
3225

3326
<br>
3427

28+
### Stateless & Stateful Sessions
29+
30+
> chdb-server queries default to stateless. Stateful sessions can be paired with Basic HTTP Auth.
31+
32+
![image](https://github.com/chdb-io/chdb-server/assets/1423657/dee938a2-ec2a-4b4a-87a9-458a6db791a0)
33+
34+
<br>
35+
3536
### ClickHouse Play
3637
chdb-server is compatible with the ClickHouse Play query interface:
3738
<a href="https://chdb.fly.dev/?user=default#U0VMRUNUCiAgICB0b3duLAogICAgZGlzdHJpY3QsCiAgICBjb3VudCgpIEFTIGMsCiAgICByb3VuZChhdmcocHJpY2UpKSBBUyBwcmljZQpGUk9NIHVybCgnaHR0cHM6Ly9kYXRhc2V0cy1kb2N1bWVudGF0aW9uLnMzLmV1LXdlc3QtMy5hbWF6b25hd3MuY29tL2hvdXNlX3BhcnF1ZXQvaG91c2VfMC5wYXJxdWV0JykKR1JPVVAgQlkKICAgIHRvd24sCiAgICBkaXN0cmljdApMSU1JVCAxMA==" target="_blank">

main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,34 @@ def clickhouse():
5656
if database:
5757
query = f"USE {database}; {query}".encode()
5858

59-
result, errmsg = chdb_query_with_errmsg(query, format)
59+
result, errmsg = chdb_query_with_errmsg(query.strip(), format)
6060
if len(errmsg) == 0:
6161
return result, 200
6262
return errmsg, 400
6363

6464
@app.route('/', methods=["POST"])
6565
@auth.login_required
6666
def play():
67-
query = request.get_data() or None
68-
query_param = request.args.get('query', default="", type=str)
67+
query = request.args.get('query', default=None, type=str)
68+
body = request.get_data() or None
6969
format = request.args.get('default_format', default="TSV", type=str)
7070
database = request.args.get('database', default="", type=str)
7171

72-
if not query and query_param:
73-
query = f"{query_param}".encode()
72+
if query is None:
73+
query = b""
74+
else:
75+
query = query.encode('utf-8')
76+
if body is not None:
77+
query = query + "\n".encode('utf-8') + body
7478

75-
elif query and query_param:
76-
query_param = f"{query_param} ".encode()
77-
query = query_param + query
78-
7979
if not query:
8080
return "Error: no query parameter provided", 400
8181

8282
if database:
8383
database = f"USE {database}; ".encode()
8484
query = database + query
8585

86-
result, errmsg = chdb_query_with_errmsg(query, format)
86+
result, errmsg = chdb_query_with_errmsg(query.strip(), format)
8787
if len(errmsg) == 0:
8888
return result, 200
8989
return errmsg, 400

0 commit comments

Comments
 (0)