File tree 2 files changed +9
-13
lines changed
web/playground/src/workbench
2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,9 @@ class Workbench extends React.Component {
40
40
componentDidMount ( ) {
41
41
this . props . setCallables ( { loadFile : ( f , c ) => this . loadFile ( f , c ) } ) ;
42
42
43
- this . duckdb = duckdb . init ( ) ;
43
+ if ( ! this . duckdb ) {
44
+ this . duckdb = duckdb . init ( ) ;
45
+ }
44
46
}
45
47
46
48
beforeEditorMount ( monaco ) {
Original file line number Diff line number Diff line change @@ -40,24 +40,18 @@ export const CHINOOK_TABLES = [
40
40
41
41
async function registerChinook ( db ) {
42
42
const baseUrl = `${ window . location . href } data/chinook` ;
43
- const http = duckdb . DuckDBDataProtocol . HTTP ;
44
43
45
44
await Promise . all (
46
- CHINOOK_TABLES . map ( ( table ) =>
47
- db . registerFileURL (
48
- `${ table } .csv` ,
49
- `${ baseUrl } /${ table } .csv` ,
50
- http ,
51
- false ,
52
- ) ,
53
- ) ,
45
+ CHINOOK_TABLES . map ( async ( table ) => {
46
+ const res = await fetch ( `${ baseUrl } /${ table } .csv` ) ;
47
+
48
+ db . registerFileText ( `${ table } .csv` , res ) ;
49
+ } ) ,
54
50
) ;
55
51
56
52
const c = await db . connect ( ) ;
57
53
for ( const table of CHINOOK_TABLES ) {
58
- await c . query ( `
59
- CREATE TABLE ${ table } AS SELECT * FROM read_csv_auto('${ table } .csv');
60
- ` ) ;
54
+ await c . insertCSVFromPath ( `${ table } .csv` , { name : table , detect : true } ) ;
61
55
}
62
56
c . close ( ) ;
63
57
}
You can’t perform that action at this time.
0 commit comments