From 026bc070ba07b113e39af534c156aff7b1bdf4ae Mon Sep 17 00:00:00 2001 From: HishamElamir Date: Mon, 31 Jul 2023 16:03:24 +0300 Subject: [PATCH] adding export to oracle db feature --- camelot/core.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/camelot/core.py b/camelot/core.py index 15eb2615..90a54835 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -2,6 +2,7 @@ import os import sqlite3 +import cv_Oracle import zipfile import tempfile from itertools import chain @@ -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