From 7861aeb06e4df6c56e38a9db2e60cd243102770e Mon Sep 17 00:00:00 2001 From: Daniel Frank Date: Fri, 25 Jan 2019 14:55:17 -0800 Subject: [PATCH] cleanup _pandas --- omniduct/databases/hiveserver2.py | 5 ++--- omniduct/databases/presto.py | 11 +++++------ omniduct/databases/sqlalchemy.py | 6 +++--- requirements.txt | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/omniduct/databases/hiveserver2.py b/omniduct/databases/hiveserver2.py index ba018e9..cc88f97 100644 --- a/omniduct/databases/hiveserver2.py +++ b/omniduct/databases/hiveserver2.py @@ -16,7 +16,6 @@ from .base import DatabaseClient from ._schemas import SchemasMixin -from . import _pandas class HiveServer2Client(DatabaseClient, SchemasMixin): @@ -301,8 +300,8 @@ def _dataframe_to_table( "and try again." ) try: - return _pandas.to_sql( - df=df, name=table.table, schema=table.schema, con=self._sqlalchemy_engine, + return pd.io.sql.to_sql( + frame=df, name=table.table, schema=table.schema, con=self._sqlalchemy_engine, index=False, if_exists=if_exists, **kwargs ) except Exception as e: diff --git a/omniduct/databases/presto.py b/omniduct/databases/presto.py index f63edbf..17c4bec 100644 --- a/omniduct/databases/presto.py +++ b/omniduct/databases/presto.py @@ -3,10 +3,10 @@ import ast import logging import re +import six import sys -import pandas.io.sql -import six +import pandas as pd from interface_meta import override from future.utils import raise_with_traceback @@ -15,7 +15,6 @@ from .base import DatabaseClient from ._schemas import SchemasMixin -from . import _pandas class PrestoClient(DatabaseClient, SchemasMixin): @@ -127,7 +126,7 @@ def _execute(self, statement, cursor, wait, session_properties): status = cursor.poll() logger.progress(100, complete=True) return cursor - except (DatabaseError, pandas.io.sql.DatabaseError) as e: + except (DatabaseError, pd.io.sql.DatabaseError) as e: # Attempt to parse database error, before ultimately reraising the same # exception, maintaining the full stacktrace. exception, exception_args, traceback = sys.exc_info() @@ -185,8 +184,8 @@ def _dataframe_to_table(self, df, table, if_exists='fail', **kwargs): default to `self.catalog`. """ table = self._parse_namespaces(table, defaults={'schema': self.username}) - return _pandas.to_sql( - df=df, name=table.table, schema=table.schema, con=self._sqlalchemy_engine, + return pd.io.sql.to_sql( + frame=df, name=table.table, schema=table.schema, con=self._sqlalchemy_engine, index=False, if_exists=if_exists, **kwargs ) diff --git a/omniduct/databases/sqlalchemy.py b/omniduct/databases/sqlalchemy.py index b25f084..966f25d 100644 --- a/omniduct/databases/sqlalchemy.py +++ b/omniduct/databases/sqlalchemy.py @@ -1,12 +1,12 @@ from __future__ import absolute_import +import pandas as pd from interface_meta import override from omniduct.utils.debug import logger from .base import DatabaseClient from ._schemas import SchemasMixin -from . import _pandas class SQLAlchemyClient(DatabaseClient, SchemasMixin): @@ -102,8 +102,8 @@ def _query_to_table(self, statement, table, if_exists, **kwargs): @override def _dataframe_to_table(self, df, table, if_exists='fail', **kwargs): - return _pandas.to_sql( - df=df, name=table.table, schema=table.database, con=self.engine, + return pd.io.sql.to_sql( + frame=df, name=table.table, schema=table.database, con=self.engine, index=False, if_exists=if_exists, **kwargs ) diff --git a/requirements.txt b/requirements.txt index 73bf0d1..59f75e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,6 @@ decorator progressbar2>=3.30.0 wrapt jinja2 -pandas>=0.17.1 +pandas>=0.24.0 sqlparse sqlalchemy