Skip to content

Commit

Permalink
cleanup _pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
danfrankcb committed Jan 25, 2019
1 parent c49b9eb commit 7861aeb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions omniduct/databases/hiveserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from .base import DatabaseClient
from ._schemas import SchemasMixin
from . import _pandas


class HiveServer2Client(DatabaseClient, SchemasMixin):
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions omniduct/databases/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -15,7 +15,6 @@

from .base import DatabaseClient
from ._schemas import SchemasMixin
from . import _pandas


class PrestoClient(DatabaseClient, SchemasMixin):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
)

Expand Down
6 changes: 3 additions & 3 deletions omniduct/databases/sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ decorator
progressbar2>=3.30.0
wrapt
jinja2
pandas>=0.17.1
pandas>=0.24.0
sqlparse
sqlalchemy

0 comments on commit 7861aeb

Please sign in to comment.