Skip to content

c0de4un/go-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

database

Golang based database realization

Description

Example project of database realization using drivers and models

Requirements

  • Go 1.17+;

Test

  • $go test

Examples:

Connect/Disconnect

config := database.LoadConfig("database.cfg")

driver, err := database.NewDriver(database.FILE_DRIVER)
if err != nil {
  log.Fatal(err)
}

err = driver.Configure(config)
if err != nil {
  log.Fatal(err)
}

connection, err := driver.Connect()
if err != nil {
  log.Fatal(err)
}

// Read    . . .
// Iterate . . .
// Write   . . .

defer connection.Disconnect()

Read/Write

// var driver database.IDriver (FileDriver)
// var query database.IQuery (FileQuery)
defer driver.Disconnect()

row := driver.ReadRow("users", query)

row.SetCol("name", "John")

driver.WriteRow(row)

Building a Query

// var driver database.IDriver (FileDriver)
// var query database::IQuery
query := driver.NewQuery()

query.Select("users", "*")
query.From("users")
query.Where("users", "id", "=", "1")
// var row database.Row
row := query.GetRow()

fmt.Println("user name is ", row.GetCol("name"))

Releases

No releases published

Packages

No packages published

Languages