Go

Work with SQLite3 in Go

using github.com/mattn/go-sqlite3.

Image for post
Image for post
Photo by Kristaps Ungurs on Unsplash

https://github.com/mattn/go-sqlite3 has more than 4.4k starts at this time. So I think we can count on that 💃.

First to install go-sqlite3 using go-mod

Connect and set max_idle_connection (for the case we might use concurrency).

defer for close the db after all the around functions finished calling.

Example for query data:

Here we want to pass parameter to the query, we can use $ for the param.

Use row.Next() to iterate and fetch records from result cursor.

That’s it.

Hope it helps.

Thanks for reading my post.

~~ PEACE~~

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store