MCPcopy Create free account
hub / github.com/araddon/qlbridge / tableFromSQL

Function tableFromSQL

datasource/sqlite/source.go:161–179  ·  view source on GitHub ↗
(name, sqls string)

Source from the content-addressed store, hash-verified

159}
160
161func tableFromSQL(name, sqls string) *schema.Table {
162 t := schema.NewTable(name)
163 //u.Debugf("%s %v", name, sqls)
164 cols := strings.Split(sqls, "\n")
165 cols = cols[1 : len(cols)-1]
166 for _, cols := range cols {
167 parts := strings.Split(strings.Trim(cols, " \t,"), " ")
168 if len(parts) < 2 {
169 continue
170 }
171 colName := expr.IdentityTrim(parts[0])
172 // NewFieldBase(name string, valType value.ValueType, size int, desc string)
173 t.AddField(schema.NewFieldBase(colName, TypeFromString(parts[1]), 255, ""))
174 // u.Debugf("%d %v", i, parts)
175 // u.Debugf("%q", expr.IdentityTrim(parts[0]))
176 }
177 t.SetColumnsFromFields()
178 return t
179}

Callers 1

SetupMethod · 0.85

Calls 6

AddFieldMethod · 0.95
SetColumnsFromFieldsMethod · 0.95
NewTableFunction · 0.92
IdentityTrimFunction · 0.92
NewFieldBaseFunction · 0.92
TypeFromStringFunction · 0.85

Tested by

no test coverage detected