sql_connection

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

README

Go Sql


Description

This is simple package to connect sql database

Usage Example

package main

import (
    "fmt"
    "github.com/root27/go-sql"
)

func main() {
    
    db,err := sql_connection.ConnectDB("sql") // sql is the name in the .env file

    if err != nil {
        fmt.Println(err)
    }

	defer sql_connection.CloseDB(db) //Close db


    //Ping db

    sql_connection.PingDB(db)

    

   

	fmt.Println("Connected to DB")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB added in v0.0.4

func CloseDB(db *sql.DB)

func ConnectDB

func ConnectDB(envName string) (*sql.DB, error)

func GetTable added in v0.0.4

func GetTable(db *sql.DB, table string) (*sql.Rows, error)

func LoadUri

func LoadUri(url string) string

func PingDB added in v0.0.4

func PingDB(db *sql.DB)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL