Mirror

Volodymyr Tkach 855109b0ab Capitalize user names 2 years ago
db 855109b0ab Capitalize user names 2 years ago
gosql 855109b0ab Capitalize user names 2 years ago
.gitignore 3046e58392 Initial commit 2 years ago
LICENSE 3046e58392 Initial commit 2 years ago
Makefile bb558b9617 Remove lint warning 2 years ago
README.md 48f2b99ef3 Add some example 2 years ago
go.mod f7cb2aa407 Add Transaction method 2 years ago
go.sum f7cb2aa407 Add Transaction method 2 years ago
main.go 855109b0ab Capitalize user names 2 years ago

README.md

golang-sql

Go bindings library for MySQL, PostgreSQL and SQLite

Features

  • Multiple storages: MySQL, PostgreSQL, SQLite
  • Debug mode for tracking SQL queries
  • Transactions is supported
  • Transactions helpers
  • Database migrations
  • Simple usage

This library allow you to faster make your development if you need to use/support multiple database engines such MySQL, PostgreSQL or/and SQLite. For example you can make web service and give ability to choose storage type. Or you can use SQLite for tests or for demo version and MySQL or PostgreSQL for production. Migrations (thanks to dbmate) is suported out of box and full SQL messages for debugging. Note: please use PostgreSQL parameter placeholders even if MySQL is used, it will be automatically replaced with ?

Used amacneil/dbmate inside the project for creating connections (please review dbmate docs) and for migrations, so next schemes is supported:

# MySQL connection:
mysql://username:password@127.0.0.1:3306/database?parseTime=true

# MySQL through the socket:
mysql://username:password@/database?socket=/var/run/mysqld/mysqld.sock

# PostgreSQL connection:
postgres://username:password@127.0.0.1:5432/database?sslmode=disable
postgresql://username:password@127.0.0.1:5432/database?sslmode=disable

# SQLite file:
sqlite:///data/database.sqlite
sqlite3:///data/database.sqlite

Examples