From d335bff6d768b206d33a59f3784b7639d8bdc011 Mon Sep 17 00:00:00 2001 From: prakash-trifacta Date: Wed, 11 Sep 2019 12:36:08 -0700 Subject: [PATCH] remove sqlite3 --- camelot/cli.py | 2 +- camelot/core.py | 30 +----------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/camelot/cli.py b/camelot/cli.py index 0298992..394706a 100644 --- a/camelot/cli.py +++ b/camelot/cli.py @@ -43,7 +43,7 @@ pass_config = click.make_pass_decorator(Config) @click.option( "-f", "--format", - type=click.Choice(["csv", "json", "excel", "html", "sqlite"]), + type=click.Choice(["csv", "json", "excel", "html"]), help="Output file format.", ) @click.option("-z", "--zip", is_flag=True, help="Create ZIP archive.") diff --git a/camelot/core.py b/camelot/core.py index b7a02b1..3c7a5f3 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import os -import sqlite3 import zipfile import tempfile from itertools import chain @@ -635,25 +634,6 @@ class Table(object): with open(path, "w") as f: f.write(html_string) - def to_sqlite(self, path, **kwargs): - """Writes Table to sqlite database. - - For kwargs, check :meth:`pandas.DataFrame.to_sql`. - - Parameters - ---------- - path : str - Output filepath. - - """ - kw = {"if_exists": "replace", "index": False} - kw.update(kwargs) - conn = sqlite3.connect(path) - table_name = "page-{}-table-{}".format(self.page, 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 @@ -720,7 +700,7 @@ class TableList(object): path : str Output filepath. f : str - File format. Can be csv, json, excel, html and sqlite. + File format. Can be csv, json, excel, html. compress : bool Whether or not to add files to a ZIP archive. @@ -748,11 +728,3 @@ class TableList(object): zipname = os.path.join(os.path.dirname(path), root) + ".zip" with zipfile.ZipFile(zipname, "w", allowZip64=True) as z: z.write(filepath, os.path.basename(filepath)) - elif f == "sqlite": - filepath = os.path.join(dirname, basename) - for table in self._tables: - table.to_sqlite(filepath) - if compress: - zipname = os.path.join(os.path.dirname(path), root) + ".zip" - with zipfile.ZipFile(zipname, "w", allowZip64=True) as z: - z.write(filepath, os.path.basename(filepath))