Skip to content

CLI: Add -f [FILE] argument that allows execution of a file #15050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

Mytherin
Copy link
Collaborator

Usage:

duckdb -f [FILE]

Similar to -c, but reads the commands from a file.

Note that this seems similar to -init [FILE] at first glance as well, but there are several differences:

  • -f [FILE] exits after it is done executing commands
  • -init [FILE] replaces the reading of ~/.duckdbrc, -f does not
  • -f [FILE] can be executed multiple times
  • -f [FILE] plays "nicely" with -c - commands are executed in the same order as they appear

For example:

echo 'create table tbl(i int);' > create.sql
echo 'insert into tbl values (42), (84);' > load.sql
duckdb -f create.sql -f load.sql -c "SELECT SUM(i) FROM tbl"
┌────────┐
│ sum(i) │
│ int128 │
├────────┤
│    126 │
└────────┘

@Mytherin
Copy link
Collaborator Author

Mytherin commented Nov 30, 2024

A work-around for the current client is to use -c ".read [FILE]", which achieves the same behavior (I have been using this a bunch in the past few days and figured this should just be a dedicated option :))

@Mytherin Mytherin merged commit ec03be1 into duckdb:main Nov 30, 2024
42 checks passed
@Mytherin Mytherin deleted the shellfarg branch December 8, 2024 06:51
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 27, 2024
max_temp_directory_size - print "90% of available disk space" as value if temp directory is not initialized (duckdb/duckdb#15057)
CLI: Add -f [FILE] argument that allows execution of a file (duckdb/duckdb#15050)
[pystubs] Fix type of `proto` parameter in `from_substrait` methods. (duckdb/duckdb#15004)
Add `require ram` to test runner, and use to limit distinct_grouping_tpch.test (duckdb/duckdb#15048)
github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Dec 27, 2024
max_temp_directory_size - print "90% of available disk space" as value if temp directory is not initialized (duckdb/duckdb#15057)
CLI: Add -f [FILE] argument that allows execution of a file (duckdb/duckdb#15050)
[pystubs] Fix type of `proto` parameter in `from_substrait` methods. (duckdb/duckdb#15004)
Add `require ram` to test runner, and use to limit distinct_grouping_tpch.test (duckdb/duckdb#15048)
github-actions bot added a commit to duckdb/duckdb-r that referenced this pull request Dec 27, 2024
max_temp_directory_size - print "90% of available disk space" as value if temp directory is not initialized (duckdb/duckdb#15057)
CLI: Add -f [FILE] argument that allows execution of a file (duckdb/duckdb#15050)
[pystubs] Fix type of `proto` parameter in `from_substrait` methods. (duckdb/duckdb#15004)
Add `require ram` to test runner, and use to limit distinct_grouping_tpch.test (duckdb/duckdb#15048)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation Use for issues or PRs that require changes in the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant