remove sqlite3

pull/51/head
prakash-trifacta 2019-09-11 12:36:08 -07:00
parent 7ecfcad239
commit d335bff6d7
2 changed files with 2 additions and 30 deletions

View File

@ -43,7 +43,7 @@ pass_config = click.make_pass_decorator(Config)
@click.option( @click.option(
"-f", "-f",
"--format", "--format",
type=click.Choice(["csv", "json", "excel", "html", "sqlite"]), type=click.Choice(["csv", "json", "excel", "html"]),
help="Output file format.", help="Output file format.",
) )
@click.option("-z", "--zip", is_flag=True, help="Create ZIP archive.") @click.option("-z", "--zip", is_flag=True, help="Create ZIP archive.")

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sqlite3
import zipfile import zipfile
import tempfile import tempfile
from itertools import chain from itertools import chain
@ -635,25 +634,6 @@ class Table(object):
with open(path, "w") as f: with open(path, "w") as f:
f.write(html_string) 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): class TableList(object):
"""Defines a list of camelot.core.Table objects. Each table can """Defines a list of camelot.core.Table objects. Each table can
@ -720,7 +700,7 @@ class TableList(object):
path : str path : str
Output filepath. Output filepath.
f : str f : str
File format. Can be csv, json, excel, html and sqlite. File format. Can be csv, json, excel, html.
compress : bool compress : bool
Whether or not to add files to a ZIP archive. 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" zipname = os.path.join(os.path.dirname(path), root) + ".zip"
with zipfile.ZipFile(zipname, "w", allowZip64=True) as z: with zipfile.ZipFile(zipname, "w", allowZip64=True) as z:
z.write(filepath, os.path.basename(filepath)) 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))