Skip to content

miraclew/ssql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ssql

ssql package provide some simple methods to make it easier to work with SQL in GO.

ssql is not a full featured ORM library, it's a simple wrapper of standard database/sql package

Example

Open connection

db, err := ssql.Open("mysql", "user:pass@tcp(localhost:3306)/dbname?parseTime=true")

Select one row

var item Item
err := db.Select("select * from items where id=?", 50).Value(&item)

Select rows

var items []Item
err := db.Select("select * from items").Values(&items)

Select scalar value

v, err := db.Select("select count(*) from items").Int()