-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
import argparse | ||
from .__init__ import query | ||
|
||
def main(): | ||
prog = 'python -m chdb' | ||
description = ('''A simple command line interface for chdb | ||
to run SQL and output in specified format''') | ||
parser = argparse.ArgumentParser(prog=prog, description=description) | ||
parser.add_argument('sql', nargs=1, | ||
type=str, | ||
help='sql, e.g: select 1112222222,555') | ||
parser.add_argument('format', nargs='?', | ||
type=str, | ||
help='''sql result output format, | ||
e.g: CSV, Dataframe, JSON etc, | ||
more format checkout on | ||
https://clickhouse.com/docs/en/interfaces/formats''', | ||
default="CSV") | ||
options = parser.parse_args() | ||
sql = options.sql[0] | ||
output_format = options.format | ||
res = query(sql, output_format) | ||
if output_format.lower() == 'dataframe': | ||
temp = res | ||
else: | ||
temp = res.data() | ||
print(temp, end="") | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters