diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..ba9207f --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..161f7bb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch file", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${file}", + "cwd": "${fileDirname}" + } + ] +} \ No newline at end of file diff --git a/examples/sql.go b/examples/sql.go new file mode 100644 index 0000000..5aa59e3 --- /dev/null +++ b/examples/sql.go @@ -0,0 +1,46 @@ +package main + +// #cgo CFLAGS: -g -Wall -I${SRCDIR}/../include +// #cgo LDFLAGS: -L${SRCDIR}/../target/debug -ldatafusion +// #include +// #include +// #include +import "C" +import ( + "fmt" + "unsafe" +) + +func main() { + datafusionlib := C.df_session_context_new() + if datafusionlib != nil { + s := C.CString("SELECT 100;") + defer C.free(unsafe.Pointer(s)) + + var perror unsafe.Pointer + + data_frame := C.df_session_context_sql( + datafusionlib, s, (**C.struct_DFError_)(unsafe.Pointer(&perror))) + + defer C.free(unsafe.Pointer(data_frame)) + + x := (*[2]uintptr)(unsafe.Pointer(&perror)) + if x[0] != 0 { + message := C.df_error_get_message((*C.struct_DFError_)(perror)) + fmt.Println(C.GoString(message)) + C.df_error_free((*C.struct_DFError_)(perror)) + return + } + + C.df_data_frame_show(data_frame, (**C.struct_DFError_)(unsafe.Pointer(&perror))) + y := (*[2]uintptr)(unsafe.Pointer(&perror)) + if y[0] != 0 { + message := C.df_error_get_message((*C.struct_DFError_)(perror)) + fmt.Println(C.GoString(message)) + C.df_error_free((*C.struct_DFError_)(perror)) + return + } + + } + +} diff --git a/examples/sql.py b/examples/sql.py index 5cd7dc5..5dac587 100755 --- a/examples/sql.py +++ b/examples/sql.py @@ -53,6 +53,7 @@ try: error = (ctypes.c_void_p * 1)() try: + data_frame = datafusion.df_session_context_sql( context, b'SELECT 1;', ctypes.pointer(error)) if error[0] is not None: