I have tried to find the solution for this problem, but keep running my head at the wall with this one. This function is part of a Go SQL wrapper, and the function getJSON is called to extract the informations from the sql response. The problem is, that the id parameter becomes jibberish and does not match the desired response,
Tag: go
sql golang invalid memory address or nil pointer dereference when do query
i am trying to insert data after the connection, when i command the logic of INSERT… i was able to connect to the database, but when i uncommand them , i got error here is my function : I have tried to do the same thing also like this article go sql and have the same issue do I wrong
Golang, database/sql, Postgres – is using QueryRow with an INSERT bad practice when you need the result?
The Go database/sql Postgres adapter does not support LastInsertId. From the docs: pq does not support the LastInsertId() method of the Result type in database/sql. To return the identifier of an INSERT (or UPDATE or DELETE), use the Postgres RETURNING clause with a standard Query or QueryRow call. But the Go database/sql docs recommend not using Query to modify the
How do I create a structure for a dynamic SQL query?
In my Golang application I make SQL request to the database. Usually, in the SQL query, I specify the columns that I want to get from the table and create a structure based on it. You can see an example of the working code below. QUESTION: What should I do if I don’t know the number and name of columns
Scan row into slice
I want to Scan a sql.Row into a slice like so: but I am getting this error: 2020/02/23 20:05:14 raw query: SELECT * FROM user_table LIMIT 500 2020/02/23 20:05:14 sql: expected 6 destination arguments in Scan, not 0 anyone know how to make this generic without using a slice? Answer You can do it this way: on the internet they
What are the differences between QueryRow and Exec in Golang SQL package?
In Golang SQL package there are QueryRow and Exec for executing query. If I’m executing insertion query inside transaction, which is better to be used in term of performance? err = tx.QueryRow(query, …
How to create SQL query with multiple JSON parameters in golang application?
As you can see in my Golang application I have an array called layers. I want to insert data of that array to the table of the PostgreSQL database. My question is how to create such SQL query in the application? QUERY: Answer Because I cannot comment, I assume that: You’re using golang’s database/sql or similar package. In your database,
How to filter table with entity from other tables related by many to many relationship using GORM?
I have Product table which is connected with the other two tables Categorie & AttributeValue using many to many relationships. I am using GORM as an ORM. go struct for those tables are like bellow….
How to set where clause dynamically in GORM
I will receive a map[string][]string. For each key in the map i want to add where clause like bellow. inFilter := map[string][]string{“product_id”: []string{“3”, “69”}} for key, value := range …
Golang db query using slice IN clause
Can someone explain to me why this does not work? And this does I’m trying to do a simple IN clause with a slice of ints, and every solution suggested doesn’t seem very idiomatic Tried to do this, but the problem appears to be the string substitution. I’m a bit surprised that go doesn’t seem to have a graceful way