Skip to content

Commit

Permalink
Merge pull request #47 from kontext-tech/32-add-data-sources-postgresql
Browse files Browse the repository at this point in the history
feat: added support for PostgreSQL using psycopg 3
  • Loading branch information
tang2087 authored Sep 9, 2024
2 parents f25483a + 59bd7a1 commit 4f78764
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kontext_copilot/data/models/_db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Setting(Base):
class DataSourceType(str, Enum):
SQLite = "SQLite"
DuckDB = "DuckDB"
# PostgreSQL = "PostgreSQL"
PostgreSQL = "PostgreSQL"
# MySQL = "MySQL"
SQLServer = "SQLServer"
# Oracle = "Oracle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def get_data_provider(source: DataSourceModel):
DataSourceType.SQLite,
DataSourceType.DuckDB,
DataSourceType.SQLServer,
DataSourceType.PostgreSQL,
]
if source.type in supported_types:
return BaseProvider(source)
Expand Down
101 changes: 98 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ duckdb = "^1.0.0"
pyarrow = "^17.0.0"
duckdb-engine = "^0.13.1"
pyodbc = "^5.1.0"
psycopg = {extras = ["binary"], version = "^3.2.1"}
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "v$version"
Expand Down
3 changes: 3 additions & 0 deletions ui/components/data-source/create-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ watch(
} else if (newVal == DataSourceType.SQLServer) {
dataSourceCreateModel.value.connStr =
"mssql+pyodbc://user:password@host:port/databasename?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes"
} else if (newVal == DataSourceType.PostgreSQL) {
dataSourceCreateModel.value.connStr =
"postgresql+psycopg://user:password@host:port/databasename?key=value&key=value"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/types/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export interface PromptListModel {
export enum DataSourceType {
SQLite = "SQLite",
DuckDB = "DuckDB",
// PostgreSQL = "PostgreSQL",
PostgreSQL = "PostgreSQL",
// MySQL = "MySQL",
SQLServer = "SQLServer"
// Oracle = "Oracle",
Expand Down

0 comments on commit 4f78764

Please sign in to comment.