Expand description
DSN (Data Source Name) parser
DSN format:
<driver>://<username>:<password>@<protocol>(<address>)/<database>?param1=value1&...¶mN=valueNA DSN in its fullest form:
driver://username:password@protocol(address)/dbname?param=valueThe address changes depending on the protocol
For TCP/UDP address have the form host:port, example:
postgresql://user:pass@tcp(localhost:5432)/dbnameFor protocol unix (Unix domain sockets) the address is the absolute path to the socket, for example:
mysql://user@unix(/path/to/socket)/databaseFor protocol file (sqlite) use the absolute path as the address, example:
sqlite://@file(/full/unix/path/to/file.db)§percent-encode
Percent-encode username and password with characters like @, for example if password is:
sop@s
!A4T@hh'cUj7LXXvk"From the command line you can encode it with:
echo -n "sop@s" | jq -s -R -r @urior
echo -n "\!A4T@hh'cUj7LXXvk\"" | xxd -p |sed 's/../%&/g'Then you can build the dsn:
mysql://root:sop%40s@tcp(10.0.0.1:3306)/testor
mysql://root:%21%41%34%54%40%68%68%27%63%55%6a%37%4c%58%58%76%6b%22@tcp(10.0.0.1:3306)/testStructs§
- DSN
- Parsed Data Source Name (DSN) structure
- DSNBuilder
- Builder for constructing DSN strings
Enums§
- Parse
Error - Errors that can occur during DSN parsing
Functions§
- parse
- Parse a DSN string into a structured
DSNobject