sqlx Questions
4
I use https://github.com/jmoiron/sqlx to make queries to Postgres.
Is it possible to get back the whole row data when inserting a new row?
Here is the query I run:
result, err := Db.Exec("INSERT...
Serology asked 18/11, 2016 at 10:59
5
Solved
Question
When dealing with a one-to-many or many-to-many SQL relationship in Golang, what is the best (efficient, recommended, "Go-like") way of mapping the rows to a struct?
Taking the example s...
5
Solved
I have difficulty querieing for users, which is defined as:
type User struct {
ID int `db:"id" json:"id"`
UserName string `db:"username" json:"username"`
Email string `db:"email" json:"email"...
1
I have below golang code which is working fine when there is no null value in the table. But in my table some column called "MIDDLE_NAME" has null value and hence I am getting error
Scan...
Pontefract asked 4/4, 2023 at 17:23
3
Solved
Let's assume that I have two models,
type Customer struct {
Id int `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Address Address `json:"ad...
Abbatial asked 21/6, 2021 at 10:34
3
Solved
I'am trying to make a bulk insert with sqlx and golang :
for _, result := range results {
queryInsert := `INSERT INTO "DataCom_travel" (com1,com2,path,time) VALUES ($1,$2,$3,$4)`
db.MustExec(q...
Plain asked 2/2, 2020 at 13:5
1
I have error when use sqlx with postgresql : "missing destination name rec_created_by"
type Client struct {
ClientID string `json:"client_id" db:"id"`
Name string `json:"name" db:"name"`
Versio...
1
After a period of inactivity, my go web service is getting a net.OpError with message read tcp x.x.x.x:52086->x.x.x.x:24414: read: connection reset by peer when executing the first postgres sql ...
Deme asked 14/5, 2018 at 20:14
3
I have a model like this:
type Course struct {
Name string `db:"course_name"`
}
type Group struct {
Course *Course
}
type Groups []Group
And when i try to do sqlx.Select for Groups with a que...
3
Solved
I'm using sqlx with mysql database and want to query author table for names which start with certain letters. Here is the query:
sqlx.DB.Select(&authors, "SELECT * FROM author WHERE first_name...
3
Solved
I want to query a table in mysql database for values IN a slice:
var qids []int
//fill qids dynamically
err = database.SQL.Select(&quotes,
"SELECT * FROM quote WHERE qid IN $1", qids)
if err ...
1
Solved
I have searched the error and I have find two questions:
This one, but my question is not duplicate of it
And this one, but there is no answer in this question.
Here is my code:
package main
...
2
Solved
I use jmoiron/sqlx library for communicating with my PostgreSql server in my Go apps. Somewhere on my apps i have this following code:
sqlQuery := `
INSERT INTO table_to_insert (
code,
status,...
Busra asked 28/10, 2015 at 4:35
1
Solved
I have a struct with a property time:
type Basket struct {
...
Created_at time.Time `db:"created_at"`
}
with the time saved as:
basket.Created_at = time.Now().UTC()
If I save it using Ins...
1
Solved
I'm using a non-framework Go stack with sqlx, and MySQL for a web project.
I would like to log all outgoing SQL statements for debugging. Is it possible to do this? Hopefully looking to get outpu...
1
© 2022 - 2024 — McMap. All rights reserved.