#string-parser #connection #net #database #jdbc #ado

connection-string

Connection string parsing in Rust (and WebAssembly)

16 releases

0.2.0 Mar 31, 2023
0.1.14 Feb 4, 2022
0.1.13 Feb 10, 2021
0.1.12 Jan 25, 2021
0.1.10 Oct 27, 2020

#48 in WebAssembly

Download history 17689/week @ 2024-07-21 18421/week @ 2024-07-28 17549/week @ 2024-08-04 19116/week @ 2024-08-11 18834/week @ 2024-08-18 19443/week @ 2024-08-25 16089/week @ 2024-09-01 17477/week @ 2024-09-08 15264/week @ 2024-09-15 19608/week @ 2024-09-22 21951/week @ 2024-09-29 20888/week @ 2024-10-06 24665/week @ 2024-10-13 20604/week @ 2024-10-20 18997/week @ 2024-10-27 17366/week @ 2024-11-03

82,878 downloads per month
Used in 52 crates (2 directly)

MIT/Apache

45KB
898 lines

connection-string

ADO.net and JDBC connection string parsing in Rust and JavaScript

Installation for Rust

$ cargo add connection-string

Usage for JavaScript

The crate is available in npm as @pimeys/connection-string. Usage patters try to follow the Rust version as close as possible. Please see the Rust docs for more information.

JDBC:

const j = new JdbcString("jdbc:sqlserver://localhost\\INSTANCE:1433;database=master;user=SA;password={my_password;123}");

console.log(j.server_name()); // "localhost"
console.log(j.port()); // 1433
console.log(j.instance_name()); // "INSTANCE"
console.log(j.get("database")); // "master"
console.log(j.get("password")); // "my_password;123" (see escaping)
console.log(j.keys()); // ["database", "user", "password"]
console.log(j.set("password", "a;;new;;password")); // "my_password;123" (returns the old value, if available)

// "jdbc:sqlserver://localhost\INSTANCE:1433;user=SA;database=master;password=a{;;}new{;;}password"
console.log(j.to_string())

ADO.net:

const a = new AdoNetString("server=tcp:localhost,1433;user=SA;password=a{;;}new{;;}password");

console.log(a.get("password")); // a;;new;;password
console.log(a.set("user", "john")); // "SA" (returns the old value, if available)

// "server=tcp:localhost,1433;user=john;password=a{;;}new{;;}password"
console.log(j.to_string())

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

Building

The build procedure and dependencies are defined in the provided flake.nix file. Please install the unstable Nix with flakes support (Linux, macOS).

The WASM module can be built with:

nix build

This creates a link result to the current directory, containing a NodeJS package with the Rust code compiled as WASM bytecode.

Testing

Run the tests with the nix subcommand:

nix run .#test

Publishing

The updatePackageVersion command changes the package version to the Rust Cargo.toml and JavaScript package.json at the same time:

nix run .#updatePackageVersion 0.1.14

Don't forget to add the tag before publishing the library:

git tag v0.1.14

The publishing can be done separately or together with the publish command:

nix run .#publishRust
nix run .#publishJavascript

or

nix run .#publish

Please be sure you have the corresponding publishing rights in crates and npmjs.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps