Sqlstr
String manipulation/helper for SQL Query
Install / Use
/learn @imantung/SqlstrREADME
SQLSTR
String manipulation/helper for SQL Query.
Examples
Clean Query from double white space, comment, etc.
cleaned := sqlstr.Clean(`
SELECT *
FROM table -- some table comment
WHERE column1 = 'meh' /* request from tyrion*/`)
fmt.Println(cleaned)
// Output:
// SELECT * FROM table WHERE column1 = 'meh'
Obscure value
obsecured := sqlstr.Obscure(`SELECT * FROM table WHERE column1 = 'text' AND column2 = 1234 AND column3 = TRUE and column4 = 3.14`)
fmt.Println(obsecured)
// Output:
// SELECT * FROM table WHERE column1 = ? AND column2 = ? AND column3 = ? and column4 = ?
Get Table Names
queryString := sqlstr.NewQueryString(`SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;`)
tableNames := queryString.TableNames()
fmt.Println(tableNames)
// Output:
// [table1 table2]
Author
iman.tung@gmail.com
Related Skills
feishu-drive
341.0k|
things-mac
341.0kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
341.0kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
