copyout csv from postgresql, using rust postgres/cbindgen and Clang.jl to interop rust and julia together, without jirs.
Any suggestions for sharing complex data structures from Rust to Julia? like:
#[repr(C)]
pub enum DTypes {
I8 = 0,
I32 = 1,
I64 = 2,
F32 = 3,
F64 = 4,
Str = 5,
}
#[repr(C)]
pub struct DFrame {
pub width: u32,
pub height: u32,
pub fields: *mut *const u8, // field names
pub types: *mut DTypes, // field types
pub values: *mut *const c_void, // field values
}
Purpose:
Use the rust postgres library to generate a postgresql client that can be quickly imported, and provide a copyout method to quickly obtain csv results.
Prerequisites:
- Rust environment
- Julia environment with Clang.jl
- Postgresql database
- Modify the database link and test code in build.jl
Compile method:
using global julia env
- build step by step
include("build.jl")
build_rs()
build_jl()
test()
- or build once
julia build.jl
howto:
Refer to the test code in build.jl
changelog:
-
2024-10-09 v0.1.1:
- using Clang.jl to generate julia library
- use mutable struct Copyout so that rust memory can be freed auto
- refactor project name and interface
- rewrite build.jl
-
2024-10-03 v0.1.0: initial version
https://github.com/bluebug/libpq_rsjl