Rust로 작성된 gluesql 프로젝트 관련 포스팅
gluesql/gluesql: GlueSQL is quite sticky, it attaches to anywhere. (github.com)
Rust를 할 일이 없었지만, GlueSQL을 수행하려고 잠시 vscode로 수행.
GlueSQL이란 무엇인가?
GlueSQL is a SQL database library written in Rust. It provides a parser (sqlparser-rs), execution layer, and optional storage (sled) packaged into a single library. Developers can choose to use GlueSQL to build their own SQL database, or as an embedded SQL database using the default storage engine.
Tae Hoon Kim 님이 리드하고 계신 프로젝트이다.
GlueSQL 코드
우선 튜토리얼 코드 먼저 체크
use gluesql::*; fn main() { let storage = SledStorage::new("data/doc-db").unwrap(); let mut glue = Glue::new(storage); let sqls = vec![ "DROP TABLE IF EXISTS Glue;", "CREATE TABLE Glue (id INTEGER);", "INSERT INTO Glue VALUES (100);", "INSERT INTO Glue VALUES (200);", "SELECT * FROM Glue WHERE id > 100;", ]; for sql in sqls { let output = glue.execute(sql).unwrap(); println!("{:?}", output) } }
vscode에 Rust 구성
아래 문서대로 Rust analyzer를 구성하고 vscode에서 "Rust Analyzer: Run" 수행
How to launch a Rust application from Visual Studio Code? - Stack Overflow
// This is the main function fn main() { // Statements here are executed when the compiled binary is called // Print text to the console println!("Hello World!"); }
이어서, 위의 GlueSQL 코드도 수행했고 결과를 잘 확인.
실행 결과 ------------------------------ DropTable Create Insert(1) Insert(1) Select { labels: ["id"], rows: [[I64(200)]] }
GlueSQL-js
embedded SQL이라 이렇게 브라우저에서 실행도 가능하다.
gluesql/gluesql-js: GlueSQL JavaScript Interface (github.com)
sled - embedded database 역시 체크할 필요가 있다.
spacejam/sled: the champagne of beta embedded databases (github.com)
다양한 embeded 환경에서 활용 가능할 좋은 프로젝트로 예상된다.
이후에 좀더 체크 예정.