Skip to main content

Run SQL Command

The run:sql command allows you to execute raw SQL queries or files directly from the command line.

Usage

npx hysteria run:sql -d ./database/index.ts "SELECT * FROM users;"
npx hysteria run:sql -d ./database/index.ts --file ./scripts/my-query.sql
yarn hysteria run:sql -d ./database/index.ts "SELECT * FROM users;"
yarn hysteria run:sql -d ./database/index.ts --file ./scripts/my-query.sql

Options

  • -f, --file [path]: Path to the SQL file to execute.
  • -d, --datasource [path]: Path to your sql file (default export).
  • -o, --out [path]: Path to the file to save the query result.
  • -t, --tsconfig [path]: Path to the tsconfig.json file, defaults to ./tsconfig.json.

Example

npx hysteria run:sql -d ./database/index.ts -f ./scripts/init.sql
npx hysteria run:sql -d ./database/index.ts -f ./scripts/init.sql -o ./results/init.json
yarn hysteria run:sql -d ./database/index.ts -f ./scripts/init.sql
yarn hysteria run:sql -d ./database/index.ts -f ./scripts/init.sql -o ./results/init.json
yarn hysteria run:sql -d ./database/index.ts -f ./scripts/init.sql
npx hysteria run:sql -d ./database/index.ts "SELECT 1"

Back to: CLI Overview