GormParams returns the database type and connection URI
()
| 494 | |
| 495 | // GormParams returns the database type and connection URI |
| 496 | func (d *Database) GormParams() (dbType DBBackendType, uri string, err error) { |
| 497 | if err := d.Validate(); err != nil { |
| 498 | return "", "", fmt.Errorf("error validating database config: %w", err) |
| 499 | } |
| 500 | dbType = d.DbBackend |
| 501 | switch dbType { |
| 502 | case MySQLBackend: |
| 503 | uri, err = d.MySQL.ConnectionString() |
| 504 | if err != nil { |
| 505 | return "", "", fmt.Errorf("error fetching mysql connection string: %w", err) |
| 506 | } |
| 507 | case SQLiteBackend: |
| 508 | uri, err = d.SQLite.ConnectionString() |
| 509 | if err != nil { |
| 510 | return "", "", fmt.Errorf("error fetching sqlite3 connection string: %w", err) |
| 511 | } |
| 512 | default: |
| 513 | return "", "", fmt.Errorf("invalid database backend: %s", dbType) |
| 514 | } |
| 515 | return |
| 516 | } |
| 517 | |
| 518 | func (d *Database) SQLiteBlobDatabaseConfig() (Database, error) { |
| 519 | if d.DbBackend != SQLiteBackend { |