MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / GetSqliteTableInfo

Function GetSqliteTableInfo

pkg/sql2code/parser/sqlite.go:11–26  ·  view source on GitHub ↗

GetSqliteTableInfo get table info from sqlite

(dbFile string, tableName string)

Source from the content-addressed store, hash-verified

9
10// GetSqliteTableInfo get table info from sqlite
11func GetSqliteTableInfo(dbFile string, tableName string) (string, error) {
12 db, err := sqlite.Init(dbFile)
13 if err != nil {
14 return "", err
15 }
16 defer sqlite.Close(db) //nolint
17
18 var sqliteFields SqliteFields
19 sql := fmt.Sprintf("PRAGMA table_info('%s')", tableName)
20 err = db.Raw(sql).Scan(&sqliteFields).Error
21 if err != nil {
22 return "", err
23 }
24
25 return convertToSQLBySqliteFields(tableName, sqliteFields), nil
26}
27
28// SqliteField sqlite field struct
29type SqliteField struct {

Callers 2

getSQLFunction · 0.92
TestGetSqliteTableInfoFunction · 0.85

Calls 4

InitFunction · 0.92
CloseFunction · 0.92
ScanMethod · 0.45

Tested by 1

TestGetSqliteTableInfoFunction · 0.68