← 返回命令列表

Linux command

cradle-sql 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Execute a SQL query

cradle sql "[SELECT * FROM users]"

Run queries from a SQL file

cradle sql --file [queries.sql]

Execute on a specific database

cradle sql --connection [mysql] "[query]"

Export table to SQL file

cradle sql --export [table_name] > [backup.sql]

Import SQL file

cradle sql --import [backup.sql]

Show all tables

cradle sql "SHOW TABLES"

说明

cradle sql provides direct SQL access to databases configured in the Cradle framework. It allows executing queries, importing/exporting data, and performing database operations without needing a separate client. The command uses the framework's database configuration, supporting multiple connections defined in the application settings. Results can be output in various formats suitable for display or processing by other tools. This tool is useful for debugging, data inspection, and quick database operations during development. It maintains consistent authentication and connection handling with the rest of the Cradle application.

参数

--file _FILE_
Execute SQL commands from a file.
--connection _NAME_
Use a specific database connection.
--export _TABLE_
Export table data as SQL statements.
--import _FILE_
Import SQL file into the database.
--database _NAME_
Override the default database.
--format _FORMAT_
Output format: table, json, csv.
--help
Display help information.

FAQ

What is the cradle-sql command used for?

cradle sql provides direct SQL access to databases configured in the Cradle framework. It allows executing queries, importing/exporting data, and performing database operations without needing a separate client. The command uses the framework's database configuration, supporting multiple connections defined in the application settings. Results can be output in various formats suitable for display or processing by other tools. This tool is useful for debugging, data inspection, and quick database operations during development. It maintains consistent authentication and connection handling with the rest of the Cradle application.

How do I run a basic cradle-sql example?

Run `cradle sql "[SELECT * FROM users]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --file _FILE_ do in cradle-sql?

Execute SQL commands from a file.