diff --git a/crates/nu-command/src/database/commands/into_sqlite.rs b/crates/nu-command/src/database/commands/into_sqlite.rs index 7be28124f..1d3aa60c5 100644 --- a/crates/nu-command/src/database/commands/into_sqlite.rs +++ b/crates/nu-command/src/database/commands/into_sqlite.rs @@ -157,7 +157,7 @@ fn action( // create a string for sql table creation let create_statement = - format!("CREATE TABLE IF NOT EXISTS {table_name} ({table_columns_creation})"); + format!("CREATE TABLE IF NOT EXISTS [{table_name}] ({table_columns_creation})"); // prepare the string as a sqlite statement let mut stmt = conn.prepare(&create_statement).map_err(|e| { @@ -189,7 +189,7 @@ fn action( // ('dd', 'ee', 'ff') // create the string for inserting data into the table - let insert_statement = format!("INSERT INTO {table_name} VALUES {table_values}"); + let insert_statement = format!("INSERT INTO [{table_name}] VALUES {table_values}"); // prepare the string as a sqlite statement let mut stmt = conn.prepare(&insert_statement).map_err(|e| { diff --git a/crates/nu-command/src/database/values/sqlite.rs b/crates/nu-command/src/database/values/sqlite.rs index 21703d1c4..f3aa5f69e 100644 --- a/crates/nu-command/src/database/values/sqlite.rs +++ b/crates/nu-command/src/database/values/sqlite.rs @@ -364,7 +364,7 @@ fn read_single_table( call_span: Span, ctrlc: Option>, ) -> Result { - let stmt = conn.prepare(&format!("SELECT * FROM {table_name}"))?; + let stmt = conn.prepare(&format!("SELECT * FROM [{table_name}]"))?; prepared_statement_to_nu_list(stmt, call_span, ctrlc) }