Skip to content

hectorsvill/tasksql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tasksql 🫠

The tasksql module provides a lightweight wrapper around SQLite for managing tasks in a database. It includes functionality for creating tables, inserting, updating, deleting, and retrieving task data.

Setup

go get github.com/hectorsvill/tasksql

import module

import "github.com/hectorsvill/tasksql"

add import

Example use of module

Store prompt data from Google genai: _example

func main() {

	taskSql, err := tasksql.NewDB("data.db")
	if err != nil {
		log.Fatal(err)
	}
	defer taskSql.Close()

	taskSql.CreateTableIfNotExist("question")
	taskSql.CreateTableIfNotExist("answer")

	question := "Write an article about the golang net/http package."

	taskSql.Post("question", question)
	gem1 := Gemini{
		Model: Gemini_2_0_turbo,
	}
	log.Println(gem1.Model)
	answer := gem1.QueryText(question)
	taskSql.Post("answer", answer[0])
	log.Println(answer)

}

type TaskSQL struct{
	db *sql.DB
}

TaskSQL object to pass around

func NewDB(dbSourceName string) (*TaskSQL, error)

Create TaskSQL object

func (tsql TaskSQL) Close() error

Close TaskSQL object

func (tsql TaskSQL) CreateTableIfNotExist(table string) error 

Create table with createTableIfNotExist query

func (tsql TaskSQL) Post(table, text string) error

Post to db with text

func (tsql TaskSQL) DeleteWhereDeletedTrue(table string) error

Delete table from db

func (tsql TaskSQL) UpdateToDelete(table string, id int) error 

update to true by finding id

func (tsql TaskSQL) Get(table string) ([]string, error)

Get text from table

About

tasksql 🫠

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages