#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2023/4/4 18:55 # @Author : old tom # @File : dialect_connector.py # @Project : futool-db # @Desc : from common.fudb.connectors.dialect.abs_connector import CommonConnector class OracleConnector(CommonConnector): """ oracle 连接器,目前仅支持sever_name方式,SID方式待开发 """ DSN = 'oracle+cx_oracle://{0}:{1}@{2}:{3}/?service_name={4}' def __init__(self, user, password, host, port=1521, server_name='orcl'): super().__init__(self.DSN.format(user, password, host, port, server_name)) def get_conn(self): return self.engine.connect() class PostgresqlConnector(CommonConnector): """ pg连接器 """ PG_DIALECT = 'postgresql+psycopg2://{0}:{1}@{2}:{3}/{4}' def __init__(self, user, password, host, port=5432, database='postgres'): super().__init__(self.PG_DIALECT.format(user, password, host, port, database)) def get_conn(self): return self.engine.connect()