Skip to content

adding export to oracle db feature #392

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions camelot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import sqlite3
import cv_Oracle
import zipfile
import tempfile
from itertools import chain
Expand Down Expand Up @@ -664,6 +665,25 @@ def to_sqlite(self, path, **kwargs):
conn.commit()
conn.close()

def to_oracle(self, path, **kwargs):
"""Writes Table to oracle database.

For kwargs, check :meth:`pandas.DataFrame.to_sql`.

Parameters
----------
path : str
Output filepath.

"""
kw = {"if_exists": "replace", "index": False}
kw.update(kwargs)
conn = cx_Oracle.connect(path)
table_name = f"page-{self.page}-table-{self.order}"
self.df.to_sql(table_name, conn, **kw)
conn.commit()
conn.close()


class TableList(object):
"""Defines a list of camelot.core.Table objects. Each table can
Expand Down