GithubHelp home page GithubHelp logo

imantung / sqlstr Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 7 KB

String manipulation/helper for SQL Query

License: MIT License

Go 100.00%
sqlquery string-manipulation sql-parser sql-table sql-cleaner sql-obsecurer

sqlstr's Introduction

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

[email protected]

sqlstr's People

Contributors

gmhafiz avatar imantung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.