From b809f92f9cc3646572ed1d6eefbe6b900bc08894 Mon Sep 17 00:00:00 2001 From: Bibo Hao Date: Sun, 26 May 2024 19:52:42 +0800 Subject: [PATCH] update PG (#18) --- src/README.md | 4 ++-- src/aloha/db/postgres.py | 8 ++++---- src/setup.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/README.md b/src/README.md index 451f9a9..511972c 100644 --- a/src/README.md +++ b/src/README.md @@ -1,7 +1,7 @@ # Aloha! [![License](https://img.shields.io/github/license/QPod/aloha)](https://github.com/QPod/aloha/blob/main/LICENSE) -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/QPod/aloha/build)](https://github.com/QPod/aloha/actions) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/QPod/aloha-python/pip.yml?branch=main)](https://github.com/QPod/aloha-python/actions) [![Join the Gitter Chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/QPod/) [![PyPI version](https://img.shields.io/pypi/v/aloha)](https://pypi.python.org/pypi/aloha/) [![PyPI Downloads](https://img.shields.io/pypi/dm/aloha)](https://pepy.tech/badge/aloha/) @@ -21,6 +21,6 @@ Please generously STAR★ our project or donate to us! [![GitHub Starts](https: ## Getting started -```py +```shell pip install aloha[all] ``` diff --git a/src/aloha/db/postgres.py b/src/aloha/db/postgres.py index a0e8a81..4440d98 100644 --- a/src/aloha/db/postgres.py +++ b/src/aloha/db/postgres.py @@ -1,13 +1,13 @@ __all__ = ('PostgresOperator',) -import psycopg2 +import psycopg from sqlalchemy import create_engine from sqlalchemy.sql import text from .base import PasswordVault from ..logger import LOG -LOG.debug('postgres: psycopg2 version = %s' % psycopg2.__version__) +LOG.debug('postgres: psycopg2 version = %s' % psycopg.__version__) class PostgresOperator: @@ -26,8 +26,8 @@ def __init__(self, db_config, **kwargs): try: self.engine = create_engine( - 'postgresql+psycopg2://{user}:{password}@{host}:{port}/{dbname}'.format(**self._config), - connect_args=connect_args, client_encoding='utf8', encoding='utf-8', + 'postgresql+psycopg://{user}:{password}@{host}:{port}/{dbname}'.format(**self._config), + connect_args=connect_args, client_encoding='utf8', pool_size=20, max_overflow=10, pool_pre_ping=True, **kwargs ) LOG.debug("PostgresSQL connected: {host}:{port}/{dbname}".format(**self._config)) diff --git a/src/setup.py b/src/setup.py index 1a5744e..2af3cd7 100644 --- a/src/setup.py +++ b/src/setup.py @@ -14,7 +14,7 @@ dict_extra_requires = { 'build': ['Cython'], 'service': ['requests', 'tornado', 'psutil', 'pyjwt'], - 'db': ['sqlalchemy<2', 'psycopg2-binary', 'pymysql', 'elasticsearch', 'pymongo', 'redis>4.2.0'], + 'db': ['sqlalchemy', 'psycopg[binary]', 'pymysql', 'elasticsearch', 'pymongo', 'redis'], 'stream': ['confluent_kafka'], 'data': ['pandas'], 'report': ['openpyxl>=3', 'XlsxWriter'],