remove sqlite3
parent
7ecfcad239
commit
d335bff6d7
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue