Skip to content
Advertisement

Tag: go

Go SQL, scanning a row as a slice?

closing note: This question does not ask “how can I find the number of columns returned?” which is len(row.Columns()). It is asking a Go-related question concerning the rows.Scan() function. How can I extract all the columns in a row into a slice or equivalent? For example I would like to extract the data in lastcols as a slice. context: for

In go – gorm “mssql: Invalid column name ‘id’

This is my model in go } and this is my repo(that retrieve data from database): } On “http” I write this code with echo When I cal my ReadAll record rerieve data completly , it’s mean I conected to database currectly,But whene I try get data by “id” got an error that : mssql: Invalid column name ‘id’. Whet

Implement Scan and Value functions in golang

I am trying to store some golang objects in SQL database and have implemented the scanner and value interface as follows: Is there a way that I can pass the parameter to the Value() function by pointers, as I am getting a HugeParam error that the attr passed to the Value() function is too big, when trying to convert the

Multi-column IN/ANY postgres query

Sample table schema: Requirement: Fetch rows that match any of the tuples (col1, col2) presented in an array. SQL: I want to write this query in Go using the “database/sql” package with “github.com/lib/pq” driver, and that is where I am facing the problem. I can easily do this for single column IN/ANY query. for example, the following query can be

How can i unlock the Database in Go

Im a newbie in go and not the best in sql. I have a simple Table in my Database with the name of users. I store the SAM, First Name and Last Name in the table. When i now try to change something in the database, i get the error database is locked. Thats my code: decodeJSONBody and checkError work

Doing 4 way filter based on 3 tables using GORM

I’ve been trying to achieve a 4 way to join/filter based on 4 tables “Offers”, “UserPaymentMethods” and a junction table “OffersUserPaymentMethods” defined as below; So I want to filter “offers” based on payment_method_id because offer_id lives in offers_user_payment_methods which makes it a bit tricky. Front-end will send payment_method_id and I need to filter offers based on the payment_method_id that’s it.

Advertisement