Skip to content

Commit

Permalink
[BUG] Postgres support for metadata store (#1459)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - This PR fixes the dbcore code that originally connects MySQL family
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] Manual testing by connecting to Postgres

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Dec 4, 2023
1 parent aa4702b commit 661d555
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion go/coordinator/cmd/grpccoordinator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func init() {
Cmd.Flags().StringVar(&conf.SystemCatalogProvider, "system-catalog-provider", "memory", "System catalog provider")
Cmd.Flags().StringVar(&conf.Username, "username", "root", "MetaTable username")
Cmd.Flags().StringVar(&conf.Password, "password", "", "MetaTable password")
Cmd.Flags().StringVar(&conf.Address, "db-address", "127.0.0.1:3306", "MetaTable db address")
Cmd.Flags().StringVar(&conf.Address, "db-address", "127.0.0.1", "MetaTable db address")
Cmd.Flags().IntVar(&conf.Port, "db-port", 5432, "MetaTable db port")
Cmd.Flags().StringVar(&conf.DBName, "db-name", "", "MetaTable db name")
Cmd.Flags().IntVar(&conf.MaxIdleConns, "max-idle-conns", 10, "MetaTable max idle connections")
Cmd.Flags().IntVar(&conf.MaxOpenConns, "max-open-conns", 10, "MetaTable max open connections")
Expand Down
2 changes: 2 additions & 0 deletions go/coordinator/internal/grpccoordinator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
Username string
Password string
Address string
Port int
DBName string
MaxIdleConns int
MaxOpenConns int
Expand Down Expand Up @@ -69,6 +70,7 @@ func New(config Config) (*Server, error) {
Username: config.Username,
Password: config.Password,
Address: config.Address,
Port: config.Port,
DBName: config.DBName,
MaxIdleConns: config.MaxIdleConns,
MaxOpenConns: config.MaxOpenConns,
Expand Down
5 changes: 3 additions & 2 deletions go/coordinator/internal/metastore/db/dbcore/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ type DBConfig struct {
Username string
Password string
Address string
Port int
DBName string
MaxIdleConns int
MaxOpenConns int
}

func Connect(cfg DBConfig) (*gorm.DB, error) {
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local&tls=true&interpolateParams=true",
cfg.Username, cfg.Password, cfg.Address, cfg.DBName)
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d",
cfg.Address, cfg.Username, cfg.Password, cfg.DBName, cfg.Port)

ormLogger := logger.Default
ormLogger.LogMode(logger.Info)
Expand Down

0 comments on commit 661d555

Please sign in to comment.