File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1- ## import os
21import json
2+
33import chdb
44
5- def lambda_handler (event , context ):
6- query = event ['query' ] or "SELECT version()"
7- format = event ['default_format' ] or "JSONCompact"
8- res = chdb .query (query , format )
9- out = json .loads (res .data ())
5+
6+ def handler (event , context ):
7+ if "requestContext" in event :
8+ event = json .loads (event ["body" ])
9+ query = event ["query" ] if "query" in event else "SELECT version()"
10+ format = event ["default_format" ] if "default_format" in event else "JSONCompact"
11+
12+ res = chdb .query (query , format ).data ()
1013 return {
1114 "statusCode" : 200 ,
1215 "headers" : {
1316 "Content-Type" : "application/json"
1417 },
15- "body" : json .dumps (out )
18+ "body" : str ( res ) if not isinstance ( res , ( dict , list )) else json .dumps (res ),
1619 }
You can’t perform that action at this time.
0 commit comments