Skip to content

Commit

Permalink
Make execute sql call
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <[email protected]>
  • Loading branch information
rylev committed Jul 25, 2023
1 parent 4e1ed90 commit 6bbca70
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ edition = "2021"
[dependencies]
anyhow = "1.0"
bindle = { git = "https://github.com/fermyon/bindle", tag = "v0.8.2", default-features = false, features = [
"client",
"client",
] }
chrono = "0.4"
clap = { version = "3.2.24", features = ["derive", "env"] }
cloud = { path = "crates/cloud" }
cloud-openapi = { git = "https://github.com/kate-goldenring/cloud-openapi", rev = "95482744a7656553b600fdc9e91bed5812176941" }
cloud-openapi = { workspace = true }
dirs = "5.0"
dialoguer = "0.10"
tokio = { version = "1.23", features = ["full"] }
Expand Down Expand Up @@ -48,6 +48,7 @@ openssl = { version = "0.10" }

[workspace.dependencies]
tracing = { version = "0.1", features = ["log"] }
cloud-openapi = { git = "https://github.com/fermyon/cloud-openapi", rev = "c37c0f28c06a206ebe05a811c2b886290a5bab40" }

[build-dependencies]
vergen = { version = "^8.2.1", default-features = false, features = [
Expand Down
4 changes: 2 additions & 2 deletions crates/cloud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = { workspace = true }

[dependencies]
anyhow = "1.0"
cloud-openapi = { git = "https://github.com/kate-goldenring/cloud-openapi", rev = "95482744a7656553b600fdc9e91bed5812176941" }
cloud-openapi = { workspace = true }
mime_guess = { version = "2.0" }
reqwest = { version = "0.11", features = ["stream"] }
semver = "1.0"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.17", features = ["full"] }
tokio-util = { version = "0.7.3", features = ["codec"] }
Expand Down
11 changes: 2 additions & 9 deletions crates/cloud/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,20 +399,13 @@ impl Client {
.map_err(format_response_error)
}

pub async fn execute_sql(
&self,
app_id: Uuid,
database: String,
statement: String,
) -> anyhow::Result<()> {
let default = true;
pub async fn execute_sql(&self, database: String, statement: String) -> anyhow::Result<()> {
api_sql_databases_execute_post(
&self.configuration,
ExecuteSqlStatementCommand {
database,
app_id,
statement,
default,
default: false,
},
None,
)
Expand Down
10 changes: 2 additions & 8 deletions src/commands/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cloud::client::Client as CloudClient;
use cloud_openapi::models::Database;
use dialoguer::Input;

use crate::commands::{create_cloud_client, get_app_id_cloud};
use crate::commands::create_cloud_client;
use crate::opts::*;

/// Manage Fermyon Cloud SQLite databases
Expand Down Expand Up @@ -40,10 +40,6 @@ pub struct ExecuteCommand {
///Statement to execute
statement: String,

/// Name of Spin app
#[clap(name = "app", long = "app")]
pub app: String,

#[clap(flatten)]
common: CommonArgs,
}
Expand Down Expand Up @@ -93,9 +89,7 @@ impl SqliteCommand {
if !list.iter().any(|d| d.name == cmd.name) {
anyhow::bail!("No database found with name \"{}\"", cmd.name);
}
let app_id = get_app_id_cloud(&client, &cmd.app).await?;
println!("Executing SQL: {}", cmd.statement);
CloudClient::execute_sql(&client, app_id, cmd.name, cmd.statement)
CloudClient::execute_sql(&client, cmd.name, cmd.statement)
.await
.context("Problem executing SQL")?;
}
Expand Down

0 comments on commit 6bbca70

Please sign in to comment.