Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup _pandas #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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