File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 19
19
"title" : " -"
20
20
}
21
21
]
22
+ },
23
+ "/sql-cell/variable" : {
24
+ "title" : " Variable" ,
25
+ "type" : " string"
22
26
}
23
27
}
24
28
},
Original file line number Diff line number Diff line change @@ -93,8 +93,13 @@ const plugin: JupyterFrontEndPlugin<void> = {
93
93
body : JSON . stringify ( { query : source , id : database_id } )
94
94
} )
95
95
. then ( data => {
96
- if ( kernel && injection . status ) {
97
- const future = Private . transferDataToKernel ( kernel , data . data ) ;
96
+ const variable = SqlCell . getMetadata ( activeCell . model , 'variable' ) ;
97
+ if ( kernel && injection . status && variable ) {
98
+ const future = Private . transferDataToKernel (
99
+ kernel ,
100
+ data . data ,
101
+ variable
102
+ ) ;
98
103
future . done . then ( reply => {
99
104
console . log ( 'REPLY' , reply ) ;
100
105
} ) ;
@@ -394,13 +399,15 @@ namespace Private {
394
399
*/
395
400
export function transferDataToKernel (
396
401
kernel : Kernel . IKernelConnection ,
397
- data : any
402
+ data : any ,
403
+ variable ?: string
398
404
) : Kernel . IShellFuture <
399
405
KernelMessage . IExecuteRequestMsg ,
400
406
KernelMessage . IExecuteReplyMsg
401
407
> {
402
408
data = JSON . stringify ( data ) . replace ( / " / gi, '\\"' ) ;
403
- const code = `_sql_transfer_data("${ data } ")` ;
409
+ const variableStr = variable ? `, "${ variable } "` : '' ;
410
+ const code = `_sql_transfer_data("${ data } "${ variableStr } )` ;
404
411
const content : KernelMessage . IExecuteRequestMsg [ 'content' ] = {
405
412
code : code ,
406
413
stop_on_error : true
You can’t perform that action at this time.
0 commit comments