### Install ByteHouse CLI on Linux Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Download the latest release, make it executable, and optionally add it to your bashrc. ```sh curl -o bytehouse-cli -L https://github.com/bytehouse-cloud/cli/releases/download/v1.5.17.1.1/bytehouse-v1.5.17.1.1-linux-amd64 chmod +x bytehouse-cli # You might want to add this binary executable to your `~/.bashrc` as alias, or `~/.zshrc`l echo "alias bytehouse-cli=\"$(pwd)/bytehouse-cli\"" > ~/.bashrc ``` -------------------------------- ### Install ByteHouse CLI on MacOS Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Use Homebrew to tap the Bytehouse repository and install the CLI. ```sh brew tap bytehouse-cloud/homebrew-core brew install bytehouse-cli ``` -------------------------------- ### Check ByteHouse CLI Version Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Display the installed ByteHouse CLI version using the -v or --version flag. The CLI will not start when this flag is used. ```sh $ bytehouse-cli -v v1.5.2 ``` -------------------------------- ### Check ByteHouse CLI Version Source: https://context7.com/bytehouse-cloud/cli/llms.txt Display the installed ByteHouse CLI version. The CLI does not start a session when this flag is used. ```sh # Check version using short flag bytehouse-cli -v # Output: v1.5.2 ``` ```sh # Check version using long flag bytehouse-cli --version ``` -------------------------------- ### Start ByteHouse CLI Interactive Mode Source: https://context7.com/bytehouse-cloud/cli/llms.txt Launch ByteHouse CLI without a query flag to enter interactive mode where you can execute multiple queries in a session. Examples include basic SELECT and SHOW commands. ```sh # Start interactive session bytehouse-cli --user bob --account AWSXXX --password coolbob --region cn-north-1 --secure # Once connected, execute queries at the prompt: # Bytehouse » SELECT 1 # Bytehouse » SHOW DATABASES # Bytehouse » USE my_database # Bytehouse » SELECT * FROM my_table LIMIT 10 ``` -------------------------------- ### Install ByteHouse CLI on Linux via Direct Download Source: https://context7.com/bytehouse-cloud/cli/llms.txt Download the ByteHouse CLI binary directly from GitHub releases for Linux systems. Make the binary executable and add it to your shell profile for easy access. ```sh # Download the latest release curl -o bytehouse-cli -L https://github.com/bytehouse-cloud/cli/releases/download/v1.5.17.1.1/bytehouse-v1.5.17.1.1-linux-amd64 # Make it executable chmod +x bytehouse-cli # Add to your shell profile for easy access echo "alias bytehouse-cli=\"$(pwd)/bytehouse-cli\"" >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Execute SQL Script Files Source: https://context7.com/bytehouse-cloud/cli/llms.txt Run SQL scripts containing multiple statements from a file. Queries are executed sequentially, and execution stops on the first error. This example demonstrates creating a database, table, and showing its creation statement. ```sh # Create a SQL script file cat > example.sql << 'EOF' CREATE DATABASE bob_db; USE bob_db; CREATE TABLE bob_numbers ( i Int32 ) ENGINE = CnchMergeTree ORDER BY i; SHOW CREATE TABLE bob_numbers; EOF # Execute the script using input redirection bytehouse-cli -cf bytehouse_conf.toml < example.sql # Alternative: pipe the script cat example.sql | bytehouse-cli -cf bytehouse_conf.toml ``` -------------------------------- ### Install ByteHouse CLI on MacOS via Homebrew Source: https://context7.com/bytehouse-cloud/cli/llms.txt Use Homebrew to install and manage the ByteHouse CLI on macOS. This includes adding the tap and installing or upgrading the package. ```sh # Add the ByteHouse tap and install brew tap bytehouse-cloud/homebrew-core brew install bytehouse-cli # Upgrade to the latest version brew upgrade bytehouse-cli ``` -------------------------------- ### Insert Data into ByteHouse Table Source: https://context7.com/bytehouse-cloud/cli/llms.txt Insert data directly using SQL INSERT statements in both interactive and non-interactive modes. Examples show inserting single and multiple rows. ```sh # Interactive mode insertion # Bytehouse » INSERT INTO bob_db.bob_number VALUES (1), (2), (3) # Non-interactive mode insertion bytehouse-cli -cf bytehouse_conf.toml -q "INSERT INTO bob_db.bob_number VALUES (1), (2), (3)" # Insert multiple rows bytehouse-cli -cf bytehouse_conf.toml -q "INSERT INTO bob_db.bob_number VALUES (10), (20), (30), (40), (50)" ``` -------------------------------- ### Show Help Information Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Display all supported flags and their aliases for the ByteHouse CLI using the -h or --help flag. ```sh #To display all options and their alias bytehouse-cli -h ``` -------------------------------- ### Connect to ByteHouse using a Configuration File Source: https://context7.com/bytehouse-cloud/cli/llms.txt Use a TOML configuration file for cleaner credential management and additional query settings. Reference the file with the `-cf` flag. ```sh # Create configuration file: bytehouse_conf.toml cat > bytehouse_conf.toml << 'EOF' # Connection settings account = "AWSXXXXX" user = "bob" password = "coolbob" region = "cn-north-1" secure = true # Query settings ansi_sql = true EOF # Connect using the configuration file bytehouse-cli -cf bytehouse_conf.toml ``` -------------------------------- ### Display ByteHouse CLI Help and Options Source: https://context7.com/bytehouse-cloud/cli/llms.txt Display all available command-line flags and their aliases for the ByteHouse CLI. ```sh # Display help information bytehouse-cli -h ``` ```sh # Alternative long flag bytehouse-cli --help ``` -------------------------------- ### Configure ByteHouse CLI with a File Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Use a TOML configuration file to manage connection and query settings. Specify the file path using the -cf flag. ```sh $ cat bytehouse_conf.toml # Settings for connection account = "AWSXXXXX" user = "bob" password = "coolbob" region = "cn-north-1" secure = true # Settings for query Settings ansi_sql = true $ bytehouse-cli -cf bytehouse_conf.toml ``` -------------------------------- ### Run ByteHouse CLI with Flags Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Connect to Bytehouse services by providing credentials and region as command-line flags. The --secure flag is required for public domains. ```sh bytehouse-cli --user --account --password --region --secure # Example $ bytehouse-cli --user bob --account AWSXXX --password coolbob --region cn-north-1 --secure ``` -------------------------------- ### Connect to ByteHouse using Command-Line Flags Source: https://context7.com/bytehouse-cloud/cli/llms.txt Authenticate and connect to ByteHouse by providing credentials directly as command-line flags. The `--secure` flag is required when connecting to ByteHouse's public domain. ```sh # Basic connection with all required credentials bytehouse-cli --user bob --account AWSXXX --password coolbob --region cn-north-1 --secure # Flag format: -- value # Required flags: # --user Your ByteHouse username # --account Your ByteHouse account name # --password Your ByteHouse password # --region The region (e.g., cn-north-1) # --secure Enable secure connection (required for public domain) ``` -------------------------------- ### Execute SQL from Stdin Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Pipe SQL commands to the ByteHouse CLI via standard input for non-interactive execution. ```sh $ echo "select 1" | bytehouse-cli ``` -------------------------------- ### Import Data from Local Files using ByteHouse CLI Source: https://context7.com/bytehouse-cloud/cli/llms.txt Load data from local CSV or other formatted files into ByteHouse tables. Supports interactive mode with INFILE syntax or non-interactive mode via stdin redirection. ```sh # Interactive mode: Import CSV file using INFILE syntax # Bytehouse » INSERT INTO bob_db.bob_number FORMAT csv INFILE 'path/to/data.csv' ``` ```sh # Non-interactive mode: Import via stdin redirection bytehouse-cli -cf bytehouse_conf.toml -q "INSERT INTO bob_db.bob_number FORMAT csv" < path/to/data.csv ``` ```sh # Import with explicit format specification cat data.csv | bytehouse-cli -cf bytehouse_conf.toml -q "INSERT INTO bob_db.bob_number FORMAT CSV" ``` -------------------------------- ### Export Data to Local Files using ByteHouse CLI Source: https://context7.com/bytehouse-cloud/cli/llms.txt Export query results to local files using the INTO OUTFILE syntax with format specification. Supports various formats like CSV and JSONEachRow. ```sh # Export to CSV format # Bytehouse » SELECT * FROM bob_db.bob_number INTO OUTFILE 'out.csv' FORMAT csv ``` ```sh # Export with specific columns # Bytehouse » SELECT i, i * 2 as doubled FROM bob_db.bob_number INTO OUTFILE 'results.csv' FORMAT csv ``` ```sh # Export in other formats # Bytehouse » SELECT * FROM bob_db.bob_number INTO OUTFILE 'out.json' FORMAT JSONEachRow ``` -------------------------------- ### Execute SQL Queries via stdin Source: https://context7.com/bytehouse-cloud/cli/llms.txt Pipe SQL queries directly to ByteHouse CLI through standard input for flexible scripting. Supports single or multiple queries separated by semicolons. ```sh # Pipe a single query echo "SELECT 1" | bytehouse-cli -cf bytehouse_conf.toml # Pipe multiple queries (separated by semicolons) echo "SHOW DATABASES; SELECT version()" | bytehouse-cli -cf bytehouse_conf.toml ``` -------------------------------- ### Execute Single Query with -q Flag Source: https://context7.com/bytehouse-cloud/cli/llms.txt Execute a single SQL statement and exit immediately using the `-q` or `--query` flag. This is ideal for quick queries and scripting. ```sh # Execute a single query and exit bytehouse-cli -q "SELECT 1" # Query with full connection parameters bytehouse-cli --user bob --account AWSXXX --password coolbob --region cn-north-1 --secure -q "SELECT * FROM my_table LIMIT 5" # Using configuration file with query bytehouse-cli -cf bytehouse_conf.toml -q "SHOW DATABASES" ``` -------------------------------- ### Execute SQL Command and Exit Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Run a SQL command non-interactively using the -q or --query flag, and the CLI will exit after execution. ```sh $ bytehouse-cli -q "select 1" ``` -------------------------------- ### Insert Data Interactively Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Insert data into a table using an interactive SQL command. ```sh Bytehouse » INSERT INTO bob_db.bob_number VALUES (1), (2), (3) ``` -------------------------------- ### Execute SQL Script Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Run a SQL script containing multiple queries separated by semicolons. Execution stops if any query returns an error. ```sh $ cat example.sql CREATE DATABASE bob_db; USE bob_db; CREATE TABLE bob_numbers ( i Int32 ) ENGINE = CnchMergeTree ORDER BY i; SHOW CREATE TABLE bob_numbers; $ bytehouse-cli < example.sql # This is also accepted $ cat example.sql | bytehouse-cli ``` -------------------------------- ### Upgrade ByteHouse CLI on MacOS Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Upgrade the ByteHouse CLI using Homebrew. ```sh brew upgrade bytehouse-cli ``` -------------------------------- ### Insert Data from CSV File Interactively Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Load data from a local CSV file into a table using the FORMAT csv INFILE clause in interactive mode. ```sh Bytehouse » INSERT INTO bob_db.bob_number FORMAT csv INFILE 'path/to/data.csv' ``` -------------------------------- ### Export Data to CSV File Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Export query results to a local CSV file using the INTO OUTFILE syntax. ```sh Bytehouse » SELECT * FROM bob_db.bob_number INTO OUTFILE 'out.csv' format csv ``` -------------------------------- ### Insert Data from CSV File Non-Interactively Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Load data from a local CSV file non-interactively by piping the file content to the CLI with the FORMAT csv flag. ```sh $ bytehouse-cli -q "INSERT INTO bob_db.bob_number FORMAT csv" < 'path/to/data.csv' ``` -------------------------------- ### Insert Data Non-Interactively Source: https://github.com/bytehouse-cloud/cli/blob/main/README.md Execute an INSERT statement non-interactively using the -q flag. ```sh $ bytehouse-cli -q "INSERT INTO bob_db.bob_number VALUES (1), (2), (3)" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.