Skip to content

A Go package that makes it easier to run SQL queries async

License

Notifications You must be signed in to change notification settings

danielgatis/go-asql

Repository files navigation

Go - Asql

Go Report Card License MIT Go Doc

A Go package that makes it easier to run SQL queries async

Install

go get -u github.com/danielgatis/go-asql

And then import the package in your code:

import "github.com/danielgatis/go-asql"

Usage

package main

import (
	"fmt"

	"github.com/danielgatis/go-asql"
	_ "github.com/mattn/go-sqlite3"
)

func main() {
	type TestTable struct {
		ID   int
		Name string
	}

	db, _ := asql.Open("sqlite3", "file::memory:")
	db.Load("testdata/schema.sql")

	rc, _ := db.Query(`select * from test_table`)
	rows := <-rc

	records := make([]TestTable, 0)

	for rows.Next() {
		var record TestTable
		rows.Scan(&record.ID, &record.Name)
		records = append(records, record)
	}

	fmt.Print(records)
}

License

Copyright (c) 2023-present Daniel Gatis

Licensed under MIT License

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

About

A Go package that makes it easier to run SQL queries async

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages