Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

SQL Query Results Pretty Printing

License

NotificationsYou must be signed in to change notification settings

shomali11/xsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Query Results Pretty Printing

Dependencies

Examples

Example 1

package mainimport ("database/sql""fmt""github.com/shomali11/xsql""log")const (dataSourceFormat="user=%s password=%s dbname=%s sslmode=disable")funcmain() {dataSource:=fmt.Sprintf(dataSourceFormat,"<USERNAME>","<PASSWORD>","<DATABASE_NAME>")db,err:=sql.Open("<DRIVER>",dataSource)iferr!=nil {log.Fatal(err)}deferdb.Close()rows,err:=db.Query("SELECT * FROM test")iferr!=nil {log.Fatal(err)}results,err:=xsql.Pretty(rows)iferr!=nil {log.Fatal(err)}fmt.Println(results)}

Output:

 id  |      name      |         title         |         created_at          | number | decimal | active-----+----------------+-----------------------+-----------------------------+--------+---------+--------   1 | Raed Shomali   | Sr. Software Engineer | 2017-10-24T20:59:43.37154Z  |     11 | 789.123 | true   2 | Dwayne Johnson | The Rock              | 2017-10-24T21:00:31.530534Z |   1000 |     3.7 | true 300 | Steve Austin   | Stone Cold            | 2017-10-26T19:42:51.993465Z |  55000 |   55.55 | false(3 rows)

About

SQL Query Results Pretty Printing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp