library

package module
v0.0.0-...-2853686 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

XRay

Install

go get github.com/adarsh-jaiss/xray@latest

Example

MySQL
$ docker run -d \                                                                                                         
  --name mysql-employees \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=college \
  -v $PWD/data:/var/lib/mysql \
  genschsa/mysql-employees

$ export DB_PASSWORD=college
package main 

import (
    "github.com/adarsh-jaiss/xray"
)

func main() {
    config := library.Config{
        Host: "127.0.0.1",
        DatabaseName: "employees",
        Username: "root",
        Port: "3306",
        SSL: "false"
    }
    client := library.NewClient(config, xray.MySql)
    data, err := client.Tables(config.DatabaseName)
    if err != nil {
        panic(err)
    } 
    var response = []library.Table
    for _,v := range data {
        table, err := library.Schema(v)
        if err != nil {
            panic(err)
        } 
        response = response.append(table)
    }
    fmt.Println(response)
}
Postgres
$ TBD

$ export DB_PASSWORD=college
package main 

import (
    "github.com/adarsh-jaiss/xray"
)

func main() {
    config := library.Config{
        Host: "127.0.0.1",
        DatabaseName: "employees",
        Username: "root",
        Port: "3306",
        SSL: "disable"
    }
    client := library.NewClient(config, xray.Postgres)
    data, err := client.Tables(config.DatabaseName)
    if err != nil {
        panic(err)
    } 
    var response = []library.Table
    for _,v := range data {
        table, err := library.Schema(v)
        if err != nil {
            panic(err)
        } 
        response = response.append(table)
    }
    fmt.Println(response)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(dbClient *sql.DB, dbType types.DbType) (types.ISQL, error)

NewClient creates a new SQL client with the given database client and database type. It returns an error if the database type is not supported or if there is a problem creating the client.

func NewClientWithConfig

func NewClientWithConfig(dbConfig *config.Config, dbType types.DbType) (types.ISQL, error)

NewClientWithConfig creates a new SQL client with the given configuration and database type. It returns an error if the database type is not supported or if there is a problem creating the client.

Types

This section is empty.

Directories

Path Synopsis
databases

Jump to

Keyboard shortcuts

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