sqlgo

module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: LGPL-2.1

README

sqlgo

go library for easier work with sql

Installation

if you dont have mattn/go-sqlite3:
go get github.com/mattn/go-sqlite3
go get github.com/MikhailBatsin-code/sqlgo

WARNING:

if you use lib versions that older than v0.1.1 than you will need to import api package and use just Api structure or AdvancedApi after update

Api usage

import in your file needed api example: import "github.com/MikhailBatsin-code/sqlgo/api" than create api instance: sapi := api.CreateApi(db, "someTable") You can create or open db by sapi.CreateSqliteDbInstance("test.db") Wait for manual to get more information. In these versions just read source code to get some info about usage

The manual

1. Api

  1. Create a Api struct instance:
    sapi := api.CreateApiApi(db, "someTable")
    than create the table if not exists with specified columns:
    sapi.Sync("id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT")

  2. Inserting:
    use create Api instance for it:
    err := sapi.Insert("name", "muka")

  3. If you need to drop table use sapi.DropTable() method

  4. If you want to select all rows from database use sapi.SelectAll() it will return *sql.Rows

  5. If yow want to delete all rows with one condition use sapi.DeleteAllBy(name = "muka" AND id = 1) it will return to you error if something went wrong

  6. If you want delete only by id use sapi.DeleteById(1)

  7. If you want to get one row by id use sapi.SelectById(1) it will return *sql.Row

  8. If you want to update by id use sapi.UpdateById(1, name = "not muka")

  9. If you want to getComponentVersion then use function sapi.GetComponentVersion() it will return a string

  10. In next versions i will add more functions

Directories

Path Synopsis
clies

Jump to

Keyboard shortcuts

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