Skip to content

binrchq/mssql-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Server CLI

Go Reference Go Report Card License: MIT

A standalone SQL Server (MSSQL) interactive CLI client for Go applications.

Features

  • 🚀 Full T-SQL support
  • 📝 GO batch separator support
  • 🔧 System stored procedures
  • ⏱️ Query timing
  • 💾 Connection pooling
  • 📊 Table format output

Installation

go get github.com/binrchq/mssql-cli

Quick Start

package main

import (
    "log"
    "os"
    
    mssqlcli "github.com/binrchq/mssql-cli"
)

func main() {
    cli := mssqlcli.NewCLI(
        os.Stdin,
        "localhost",
        1433,
        "sa",
        "password",
        "mydb",
    )
    
    if err := cli.Connect(); err != nil {
        log.Fatal(err)
    }
    defer cli.Close()
    
    if err := cli.Start(); err != nil {
        log.Fatal(err)
    }
}

Supported Commands

T-SQL Commands

  • All standard SQL Server T-SQL syntax
  • USE <database> - Switch database

System Stored Procedures

  • sp_help [table] - Show table info
  • sp_databases - List databases
  • sp_tables - List tables
  • sp_columns <table> - List columns
  • sp_who - Show connections

Batch Separator

Use GO to execute a batch of T-SQL statements.

Special Commands

  • help - Show help
  • exit, quit - Exit
  • timing - Toggle timing
  • clear, cls - Clear screen

Requirements

  • Go 1.21 or higher
  • SQL Server 2016 or higher

Dependencies

License

MIT License - see LICENSE file for details.

Author

Maintained by binrc.

Related Projects

About

Database CLI for MSSQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages