mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-27 11:16:03 +00:00
Add postgres source
This commit is contained in:
parent
e949e6ec9f
commit
d12497a3ff
@ -98,6 +98,8 @@ Extracts:
|
|||||||
- List of databases and tables
|
- List of databases and tables
|
||||||
- Column types and schema associated with each table
|
- Column types and schema associated with each table
|
||||||
|
|
||||||
|
Extra requirements: `pip install pymysql`
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
source:
|
source:
|
||||||
type: mysql
|
type: mysql
|
||||||
@ -118,6 +120,8 @@ Extracts:
|
|||||||
- List of databases, schema, and tables
|
- List of databases, schema, and tables
|
||||||
- Column types associated with each table
|
- Column types associated with each table
|
||||||
|
|
||||||
|
Extra requirements: `pip install sqlalchemy-pytds`
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
source:
|
source:
|
||||||
type: mssql
|
type: mssql
|
||||||
@ -138,6 +142,8 @@ Extracts:
|
|||||||
- List of databases, schema, and tables
|
- List of databases, schema, and tables
|
||||||
- Column types associated with each table
|
- Column types associated with each table
|
||||||
|
|
||||||
|
Extra requirements: `pip install pyhive[hive]`
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
source:
|
source:
|
||||||
type: hive
|
type: hive
|
||||||
@ -149,6 +155,24 @@ source:
|
|||||||
# table_pattern is same as above
|
# table_pattern is same as above
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## PostgreSQL `postgres`
|
||||||
|
Extracts:
|
||||||
|
- List of databases, schema, and tables
|
||||||
|
- Column types associated with each table
|
||||||
|
|
||||||
|
Extra requirements: `pip install psycopg2-binary`
|
||||||
|
|
||||||
|
```yml
|
||||||
|
source:
|
||||||
|
type: postgres
|
||||||
|
config:
|
||||||
|
username: user
|
||||||
|
password: pass
|
||||||
|
host_port: localhost:5432
|
||||||
|
database: DemoDatabase
|
||||||
|
# table_pattern is same as above
|
||||||
|
```
|
||||||
|
|
||||||
## File `file`
|
## File `file`
|
||||||
Pulls metadata from a previously generated file. Note that the file sink
|
Pulls metadata from a previously generated file. Note that the file sink
|
||||||
can produce such files, and a number of samples are included in the
|
can produce such files, and a number of samples are included in the
|
||||||
|
|||||||
@ -79,9 +79,6 @@ setuptools.setup(
|
|||||||
# fastavro for serialization.
|
# fastavro for serialization.
|
||||||
"fastavro>=1.3.0",
|
"fastavro>=1.3.0",
|
||||||
"avro-python3>=1.8.2",
|
"avro-python3>=1.8.2",
|
||||||
# Required for certain sources/sinks.
|
|
||||||
"sqlalchemy>=1.3.23", # Required for SQL sources
|
"sqlalchemy>=1.3.23", # Required for SQL sources
|
||||||
"pymysql>=1.0.2", # Driver for MySQL
|
|
||||||
"sqlalchemy-pytds>=0.3", # Driver for MS-SQL
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -9,11 +9,13 @@ from .mce_file import MetadataFileSource
|
|||||||
from .mssql import SQLServerSource
|
from .mssql import SQLServerSource
|
||||||
from .mysql import MySQLSource
|
from .mysql import MySQLSource
|
||||||
from .hive import HiveSource
|
from .hive import HiveSource
|
||||||
|
from .postgres import PostgresSource
|
||||||
|
|
||||||
source_class_mapping: Dict[str, Type[Source]] = {
|
source_class_mapping: Dict[str, Type[Source]] = {
|
||||||
"mssql": SQLServerSource,
|
"mssql": SQLServerSource,
|
||||||
"mysql": MySQLSource,
|
"mysql": MySQLSource,
|
||||||
"hive": HiveSource,
|
"hive": HiveSource,
|
||||||
|
"postgres": PostgresSource,
|
||||||
"kafka": KafkaSource,
|
"kafka": KafkaSource,
|
||||||
# "ldap": LDAPSource,
|
# "ldap": LDAPSource,
|
||||||
"file": MetadataFileSource,
|
"file": MetadataFileSource,
|
||||||
|
|||||||
16
metadata-ingestion/src/gometa/ingestion/source/postgres.py
Normal file
16
metadata-ingestion/src/gometa/ingestion/source/postgres.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from .sql_common import SQLAlchemyConfig, SQLAlchemySource
|
||||||
|
|
||||||
|
|
||||||
|
class PostgresConfig(SQLAlchemyConfig):
|
||||||
|
# defaults
|
||||||
|
scheme = "postgresql+psycopg2"
|
||||||
|
|
||||||
|
|
||||||
|
class PostgresSource(SQLAlchemySource):
|
||||||
|
def __init__(self, config, ctx):
|
||||||
|
super().__init__(config, ctx, "postgresql")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, config_dict, ctx):
|
||||||
|
config = PostgresConfig.parse_obj(config_dict)
|
||||||
|
return cls(config, ctx)
|
||||||
@ -8,3 +8,7 @@ pytest-cov>=2.8.1
|
|||||||
pytest-docker
|
pytest-docker
|
||||||
sqlalchemy-stubs
|
sqlalchemy-stubs
|
||||||
deepdiff
|
deepdiff
|
||||||
|
|
||||||
|
# These are used in integration tests.
|
||||||
|
pymysql>=1.0.2 # Driver for MySQL
|
||||||
|
sqlalchemy-pytds>=0.3 # Driver for MS-SQL
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user