Questions tagged [gorp]

`gorp` is a package that provides a simple way to marshal Go structs to and from SQL databases. It uses the database/sql package, and should work with any compliant database/sql driver.

gorp is a package that provides a simple way to marshal Go structs to and from SQL databases. It uses the database/sql package, and should work with any compliant database/sql driver.

See more:

39 questions
12
votes
1 answer

gorp Update not updating

Im having issues updating a row in my postgresql database with gorp, im successfully able run the update using db.Exec, all columns get updated with the right information, while with gorp im only able to update the non sql.Null* fields while the…
norwat
  • 218
  • 1
  • 11
11
votes
2 answers

unsupported Scan, storing driver.Value type []uint8 into type *[]string

I have implemented rest api using golang, gin and gorp Employee structure: type Employee struct { Id int64 `db:"id" json:"id"` Firstname string `db:"firstname" json:"firstname"` Lastname string `db:"lastname" json:"lastname"` …
Prashant4224
  • 1,551
  • 1
  • 14
  • 21
11
votes
2 answers

sql/db transaction not rolling back properly with ms sql

So I can't get too specific, but I think what I can tell you will be enough to figure this out. First I'm using gorp to set things up and get the transaction. I am using the github.com/denisenkom/go-mssqldb driver. Then I run through a series of…
Matthew Clark
  • 571
  • 1
  • 9
  • 33
4
votes
2 answers

Gorm output to json

I am trying to convert a SQL Output (GORP) to JSON. I am using gorp with mySql. Here is my selected code type Mane struct { ManeId string `db:"mane_id"` Manetana string `db:"manetana"` Yajamana string `db:"yajamana"` } var manegalu…
krisho
  • 1,004
  • 7
  • 26
3
votes
1 answer

Querying Postgres composite types from golang

So I am using go-gorp to query postgres and I can't seem to query the composite type inside my table is giving an error. All I want is appropriately nested JSON response. My postgres schema is: CREATE TYPE PhoneType AS ENUM ('MOBILE', 'HOME',…
tushar
  • 741
  • 1
  • 8
  • 21
3
votes
1 answer

Golang generic method to fetch data from database

I'm trying to implement the jquery datatables server side processing in Golang. Part of that needs a generic method to select data from DB. I've posted a simplified version of what I've done below. package main import ( "gopkg.in/gorp.v1" …
Anuruddha
  • 3,187
  • 5
  • 31
  • 47
3
votes
1 answer

How to handle joins with gorp?

In a hobby project of mine, I have a struct like this: type Resource struct { Id int ParentIds []int Title string Contents []byte Resources []Resource } Each resource possibly has some sub-resources ([]Resource). I'd like to get…
Ege Özcan
  • 13,971
  • 2
  • 30
  • 51
2
votes
0 answers

Postgresql Closing statement takes a long time

In order to add millions of records to a Postgres database with constant memory consumption, I am using a thread pool with several workers as well as a gorp.Transaction. Per million records, the following code is called from different threads about…
Alechko
  • 1,406
  • 1
  • 13
  • 27
2
votes
1 answer

go - How do i use gorp select for an empty interface

Hi i am using gorp and want to use select query for any table without actually knowing its schema for that i am using the query db, err := sql.Open("mysql", "root:1234@tcp(localhost:3306)/information_schema") checkErr(err, "sql.Open failed") dbmap…
Abhishek Soni
  • 1,677
  • 4
  • 20
  • 27
2
votes
2 answers

Create table using Go-Gorp fails to set column details

Trying to create the table using Gorp-Go ORM package. Was able to successfully create the table in MySql but failed to attach column details. type Data struct { id int `db:"pid"` name string `db:",size:50"` } Gorp hook…
Itachi
  • 1,383
  • 11
  • 22
2
votes
1 answer

golang gorp insert panic

Hi I'm using gorp and mysql. when insert struct gorp return reflect.Value.Interface: cannot return value obtained from unexported field or method In gorp docs says Panics if any interface in the list has not been registered with AddTablebut I added…
jen6
  • 68
  • 8
2
votes
1 answer

Encode array to base64 in go

Here is my complete code for a function I develop: package main import ( "database/sql" "log" "encoding/xml" "github.com/gin-gonic/gin" //golang frameworks _ "github.com/go-sql-driver/mysql" "gopkg.in/gorp.v1" //work…
LeViNcE
  • 304
  • 1
  • 6
  • 15
2
votes
1 answer

golang Gorp error with SELECT

I am trying to do a SELECT from mySQL database with GORP. I am getting an error which says "reflect.Value.Interface: cannot return value obtained from unexported field or method". I have verified the DB connectivity. For example Select (*) count…
krisho
  • 1,004
  • 7
  • 26
2
votes
1 answer

Invalid memory address or nil pointer dereference when database returns empty set

When I pass event id in to DisplayScanMembers(23), if the event_id does not appear in the database, it returns an empty set. However, apparently an empty set is equivalent a nil pointer(I guess). Therefore I cannot assign the value(nil pointer) to…
WarrenV
  • 230
  • 1
  • 2
  • 9
1
vote
1 answer

Go and postgres reinterpreting integer as nil type

I'm trying to get some old code to pass its unit tests. The test that's giving me problems is here: func Test1(t *testing.T){ //Code testDevice := Device{ ID: 1, Guid:…
Errorum
  • 223
  • 4
  • 16
1
2 3