Questions tagged [go-xorm]
16 questions
7
votes
1 answer
Module declared as X but was required as Y
I'm trying to use grafana/grafana/pkg/tsdb package in my module. I don't think this problem is specific to grafana but here it goes:
$ go get -u github.com/grafana/grafana/pkg/tsdb
go: finding github.com/inconshreveable/log15 latest
go: finding…

kjq07bd
- 125
- 1
- 4
2
votes
1 answer
xorm How to convert a QueryInterface map[string]interface{} back to the xorm defined struct?
I have a database query that returns an extra calculated column along with all the mapped struct columns. I want to map it back into the struct while also being able to extract the calculated column which is not part of the struct. I can get…

Christopher
- 412
- 3
- 11
2
votes
1 answer
Store information/reference about structure
I am looking for a way to store information which struct a function should use. Each struct corresponds to certain database table.
type Record struct {
TableName string
PrimaryKey string
//XormStruct // how can I store User or Post here?
…

liepumartins
- 464
- 2
- 6
- 21
1
vote
0 answers
How to declare foreign key relationship in go-xorm for postgres?
I want to declare foreign key relation between tables using XORM in golang for postgres.
I've tried the following schema to create foreign key relationship.
type Author struct {
Id uint64 `xorm:"pk autoincr"`
Name string `xorm:"VARCHAR(128)…

Mahmood Al Rayhan
- 642
- 5
- 14
1
vote
0 answers
How to detect database disconnection , and effectively reconnect using go-xorm for databases like mysql, tiDB etc?
I need to find an effective way to attempt a reconnection , using go-xorm library. Currently if a disconnection occurs , the connection is lost and further queries fail , even if the database comes back online after some time.
Does xorm generate an…

Shourie Ganguly
- 36
- 4
1
vote
1 answer
Convert bool to tinyint golang
I am using the latest version of xorm and want to create a simple go struct as follows:
types myStruct struct {
isDeleted bool `xorm:"'isDeleted' tinyint(3)"`
}
I know the bool type in go evaluates to true and false, but I need to map it to a…

00robinette
- 497
- 5
- 16
0
votes
1 answer
why can't the go-xorm print the error message
I use xorm to connect to my mysql database,but when my mysql doesn't start,xorm cann't print error message
package main
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"xorm.io/xorm"
)
var engine *xorm.Engine
func main() {
var…

Symfonying
- 13
- 3
0
votes
0 answers
Using xorm sync table in sqlite3 occurs near "MODIFY": syntax error
I use xorm engine.Sync2 to sycn tables with sqlite3 driver. But when I sync these tables again, it prompts "near "MODIFY": syntax error". It seems that SQLite only supports synchronization once. However, I never met this problem in mysql and…

lzf
- 29
- 4
0
votes
1 answer
xorm , difference between Sync and Sync2 functions
The xorm go library has 2 function that appear similar:
// Sync the new struct changes to database, this method will automatically add
// table, column, index, unique. but will not delete or change anything.
// If you change some field, you should…

binary01
- 1,728
- 2
- 13
- 27
0
votes
1 answer
create a default number of db connections at startup golang
I want some idle db connections to always there on application startup.
I can only see MaxIdleConns and MaxOpenConns in Golang.
I don't see any setMinIdle func.
Help is appreciated.

Nitish
- 13
- 1
- 2
0
votes
0 answers
Run multiple Select queries as batch/pipeline using Xorm
Can we run multiple select queries as a batch/pipeline using Xorm Engine in Go? I have a set of 5 queries and if any of them fails my whole logic should fail, but then if they succeed I need the output from all of them. So I want to save on the…

Harshit Gupta
- 167
- 1
- 1
- 10
0
votes
0 answers
How to get a struct in graphql resolvers with xorm?
Here is the struct in models_gen.go
type Students struct {
StudentID string `json:"student_id"`
Class string `json:"class"`
TestsHistory []*TestsHistory `json:"test_history"
}
type TestsHistory…

Emily
- 137
- 1
- 2
- 8
0
votes
1 answer
xorm example not working: "runtime error: invalid memory address or nil pointer dereference"
Based on this example i tried to write a program that would return some data from a database. Unfortunately, (more-or-less) the same program structure causes memory errors here err := orm.Find(&sensorDataEntry) according to runtime console…

mspehar
- 527
- 1
- 6
- 19
0
votes
1 answer
How to get table values by xorm from Oracle DB?
I try to get values by using xorm and call engine.Find(&xxxx) method but the result object is empty.
I've checked that it can get result through engine.Query() method.
This means database connection is working correctly and .
How to put the result…

O.Takashi
- 73
- 2
- 12
0
votes
0 answers
Do I need to close sqlite3 database connection in XORM?
I use https://github.com/go-xorm/xorm for my Go software to handle database connection.
In every function I use call initdb to get new xorm database session (is it right way?)
func InitDb() (*xorm.Session, error) {
// Create new engine
engine,…

Zola Man
- 113
- 9