Comments (2)
I believe I have this same problem. I'm studying trying to make a sql query builder for Python using gopy, but I'm having a similar problem:
panic: interface conversion: interface {} is map[string]interface {}, not *map[string]interface {}
Function causing the error:
func (qb *QueryBuilder) Exec() ([]map[string]interface{}, error) {
qb.Compiler.SetOptionsBuilder(qb.Statements, qb.Simple)
result, err := qb.Compiler.Exec()
qb.Reset()
return result, err
}
qb.Compiler.Exec() function:
func (qc *QueryCompiler) Exec() ([]map[string]interface{}, error) {
query := qc.Simple.Raw.Sql
if query == "" {
query = qc.ToSQL()
}
qc.Reset()
var result []map[string]interface{}
if qc.Simple.IsDQL {
rows, err := qc.Client.Query(query)
if err != nil {
return nil, err
}
defer rows.Close()
cols, err := rows.Columns()
if err != nil {
fmt.Println(err)
}
colTypes, err := rows.ColumnTypes()
if err != nil {
fmt.Println(err)
return nil, err
}
vals := make([]interface{}, len(cols))
for i, ct := range colTypes {
switch ct.DatabaseTypeName() {
case "VARCHAR", "TEXT":
vals[i] = new(string)
case "INT":
vals[i] = new(int)
default:
vals[i] = new(interface{})
}
}
for rows.Next() {
scanArgs := make([]interface{}, len(cols))
for i := range vals {
scanArgs[i] = &vals[i]
}
err = rows.Scan(scanArgs...)
if err != nil {
fmt.Println(err)
continue
}
rowMap := make(map[string]interface{})
for i, colName := range cols {
valPtr := vals[i]
var val interface{}
switch v := valPtr.(type) {
case *string:
if v != nil {
val = *v
}
case *int:
if v != nil {
val = *v
}
default:
val = v
}
rowMap[colName] = val
}
result = append(result, rowMap)
}
} else {
_, err := qc.Client.Exec(query)
if err != nil {
return nil, err
}
}
fmt.Println("result", result)
return result, nil
}
This is the complete code: https://github.com/richecr/pythonicsqlgo
from gopy.
Related Issues (20)
- Build Dummy Example Failed in MacOS M1 HOT 2
- How hard would it be to generate C bindings instead of Python bindings? HOT 1
- Allow for fetching entire `[]byte` slice as `bytes` HOT 5
- Windows build broke without the sed hack
- Build constraints exclude all Go files in HOT 1
- "go": cannot run executable found relative to current directory HOT 3
- Best way to pass data chunks (bytes, bytearray)? HOT 1
- Build error on Windows10 HOT 2
- gopy: only one function signature arg allowed HOT 1
- cross-platform generation of Python bindings HOT 1
- Enhancement request: enable manylinux builds
- fmt.Stringer on the Go side didn't get called properly from __str__ on the Python side. HOT 1
- Add hacktoberfest topic
- No consts documentation is generated
- gopy doesn't ignore internal package HOT 2
- []byte Parameter Results in Unexpected Integer Type
- Methods with two outputs are expected to return an error, methods aren't visible from python
- Can't return a slice of slices ([][]bool) HOT 3
- Type aliases points to the underlying type not the root one, this cause issues where the autogenerated go package does not build if it links to internal packages. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gopy.