GetPostgresqlTableInfo get table info from postgres
(dsn string, tableName string)
| 10 | |
| 11 | // GetPostgresqlTableInfo get table info from postgres |
| 12 | func 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 |
| 23 | func ConvertToSQLByPgFields(tableName string, fields PGFields) (string, map[string]string) { |