Crates.io | mdsn |
lib.rs | mdsn |
version | 0.2.25 |
source | src |
created_at | 2022-04-29 14:34:05.055245 |
updated_at | 2024-06-20 02:12:37.19224 |
description | M-DSN: A Multi-address DSN(Data Source Name) parser. |
homepage | https://github.com/taosdata/taos-connector-rust |
repository | https://github.com/taosdata/taos-connector-rust.git |
max_upload_size | |
id | 577389 |
size | 53,452 |
M-DSN: A Multi-address DSN(Data Source Name) parser.
M-DSN support two kind of DSN format:
<driver>[+<protocol>]://<username>:<password>@<addresses>/<database>?<params>
<driver>[+<protocol>]://<username>:<password>@<fragment>?<params>
<driver>://<username>:<password>@<protocol>(<addresses>)/<database>?<params>
All the items will be parsed into struct Dsn.
use mdsn::Dsn;
// The two styles are equivalent.
let dsn = Dsn::parse("taos://root:taosdata@host1:6030,host2:6030/db")?;
let dsn: Dsn = "taos://root:taosdata@host1:6030,host2:6030/db".parse()?;
assert_eq!(dsn.driver, "taos");
assert_eq!(dsn.username.unwrap(), "root");
assert_eq!(dsn.password.unwrap(), "taosdata");
assert_eq!(dsn.database.unwrap(), "db");
assert_eq!(dsn.addresses.len(), 2);
assert_eq!(dsn.addresses, vec![
mdsn::Address::new("host1", 6030),
mdsn::Address::new("host2", 6030),
]);
A DSN for TDengine driver taos.
taos://root:taosdata@localhost:6030/db?timezone=Asia/Shanghai&asyncLog=1
With multi-address:
taos://root:taosdata@host1:6030,host2:6030/db?timezone=Asia/Shanghai
A DSN for unix socket:
unix:///path/to/unix.sock?param1=value
A DSN for postgresql with url-encoded socket directory path.
postgresql://%2Fvar%2Flib%2Fpostgresql/db
A DSN for sqlite db file, note that you must use prefix ./
for a relative path file.
sqlite://./file.db
License: MIT OR Apache-2.0