Skip to content
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

Run a SQL script from CLI #6

Open
lakruzz opened this issue Mar 22, 2023 · 0 comments
Open

Run a SQL script from CLI #6

lakruzz opened this issue Mar 22, 2023 · 0 comments
Labels
Template Template issue

Comments

@lakruzz
Copy link
Member

lakruzz commented Mar 22, 2023

Given that you have you CLI authorization set up correct you can run a SQL script against your PlanetScale database like this:

pscale shell sample main --org lakruzz < createdb.sql

In the command above, sample is the name of the Planetscale database you want to connect to, main is the name of the branch you want to connect to, --org lakruzz specifies the organization (a.k.a you user handle) and < createdb.sql redirects the contents of the SQL script to the shell subcommand, which is used by pscale shell to connect to the database and open a prompt - or in this case - execute the script.

The branch is not required, if the database only have one. And you can use the same command ot open an interactive SQL prompt like this:

pscale shell sample --org lakruzz

For more details see:

@lakruzz lakruzz changed the title Create tables from CLI Run a SQL script from CLI Mar 25, 2023
@lakruzz lakruzz added the Template Template issue label Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Template Template issue
Projects
None yet
Development

No branches or pull requests

1 participant