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

Function GetPostgresqlTableInfo

pkg/sql2code/parser/postgresql.go:12–20  ·  view source on GitHub ↗

GetPostgresqlTableInfo get table info from postgres

(dsn string, tableName string)

Source from the content-addressed store, hash-verified

10
11// GetPostgresqlTableInfo get table info from postgres
12func GetPostgresqlTableInfo(dsn string, tableName string) (PGFields, error) {
13 db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
14 if err != nil {
15 return nil, fmt.Errorf("GetPostgresqlTableInfo error: %v", err)
16 }
17 defer closeDB(db)
18
19 return getPostgresqlTableFields(db, tableName)
20}
21
22// ConvertToSQLByPgFields convert to mysql table ddl
23func ConvertToSQLByPgFields(tableName string, fields PGFields) (string, map[string]string) {

Callers 2

getSQLFunction · 0.92

Calls 3

closeDBFunction · 0.85
getPostgresqlTableFieldsFunction · 0.85
ErrorfMethod · 0.80

Tested by 1