Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

proxy-git.cwkhome.fun/shomali11/xsql

Package Overview
Dependencies
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-git.cwkhome.fun/shomali11/xsql

Go Modules
Version
v0.0.0-20190608141458-bf76292144df
Version published
Created
Source

xsql Build Status Go Report Card GoDoc License: MIT

SQL Query Results Pretty Printing

Dependencies

  • util github.com/shomali11/util

Examples

Example 1

package main

import (
	"database/sql"
	"fmt"
	"github.com/shomali11/xsql"
	"log"
)

const (
	dataSourceFormat = "user=%s password=%s dbname=%s sslmode=disable"
)

func main() {
	dataSource := fmt.Sprintf(dataSourceFormat, "<USERNAME>", "<PASSWORD>", "<DATABASE_NAME>")
	db, err := sql.Open("<DRIVER>", dataSource)
	if err != nil {
		log.Fatal(err)
	}

	defer db.Close()

	rows, err := db.Query("SELECT * FROM test")
	if err != nil {
		log.Fatal(err)
	}

	results, err := xsql.Pretty(rows)
	if err != 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)

FAQs

Package last updated on 08 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts