sqlgo

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 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

SqliteApi usage

import in your file needed api example: import "github.com/MikhailBatsin-code/sqlgo/sqlite" than create api instance: sapi := sqlite.CreateSqliteApi(db, "someTable") You can create or open db by sqlite.OpenOrCreateDb("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. SqliteApi

  1. Create a SqliteApi struct instance:
    sapi := sqlite.CreateSqliteApi(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 SqliteApi 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