I simplified it further and took your suggestion
Load the table twice, once to run db.query
style and once to enable sql cells. Im guessing this won’t double the read time? If so, can I get a DBClient.sql from a. DBClient.of?
Also pre-create actiontable
```js
// npm upgrade @observablehq/framework - > to upgrade
//const db = await DuckDBClient.of({afm: FileAttachment("./data/download_data.duckdb")});
// ^^ in a few weeks
import {DuckDBClient} from "npm:@observablehq/duckdb";
const db = await DuckDBClient.of({
pr: FileAttachment("./data/a_csv_data.csv"),
meta: FileAttachment("./data/a_meta.csv"),
actiontable: FileAttachment("./data/a_csv_data.csv")
});
const sql = await DuckDBClient.sql({
pr: FileAttachment("./data/a_csv_data.csv"),
meta: FileAttachment("./data/a_meta.csv"),
actiontable: FileAttachment("./data/a_csv_data.csv")
});
Set the multiple choice task chooser
```js
const types = [ {'task_types': 'ALL'},...await db.query("select distinct(task_types) from pr order by 1")].map(x => x.task_types)
const types_chooser = view(Inputs.select(types,{label: "Types",value:"ALL",multiple: 10}))
Based on choices create my where logic (simplified here)
```js
var a = '';
if( !( (types_chooser.length==0 || types_chooser.some(x => x=='ALL') ))){
a = `where task_types in ("${types_chooser.join("','")}")`;
}else{
a = `where task_types in ('${types.join("','")}')`;
}
const task_filter_sql = a ;
The SQL ought to run when task_filter_sql
is modified, the number of rows is put into id=actiontable
```sql id=actiontable_updated
CREATE OR REPLACE TABLE actiontable as select * from prompts ${task_filter_sql}
Q1. the last cell throws an error
Error: Parser Error: syntax error at or near "?"
LINE 1: ...E actiontable as select * from prompts ?
Q2: Now I can have other cells depend on actiontable_updated
- what sort of dependence is required? if I a line In the cell such as
```js
let a = actiontable_updated;
``
and I do nothing else with a
is that enough for the cell to be run when the drop downs have been selected?
Thanks much