Code Monkey home page Code Monkey logo

thombashi / sqlitebiter Goto Github PK

View Code? Open in Web Editor NEW
828.0 29.0 51.0 939 KB

A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.

Home Page: https://sqlitebiter.rtfd.io/

License: MIT License

Python 72.35% Batchfile 0.05% Shell 2.78% Jupyter Notebook 23.15% Makefile 1.20% PowerShell 0.20% Dockerfile 0.26%
sqlite csv excel google-sheets html json ltsv tsv converter cli-app jupyter-notebook ldjson jsonlines ndjson

sqlitebiter's Introduction

sqlitebiter

Summary

sqlitebiter is a CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.

PyPI package version Supported Python versions CI status of Linux/macOS/Windows CodeQL

Features

Usage

Create SQLite database from files

image

Create SQLite database from URL

Following is an example that converts HTML table tags within a web page to SQLite tables by the web page URL.

Example
$ sqlitebiter url "https://en.wikipedia.org/wiki/Comparison_of_firewalls"
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html1' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html2' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html3' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html4' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html5' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html6' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html7' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html8' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html9' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html10' table
[INFO] sqlitebiter url: convert 'Comparison_of_firewalls' to 'Comparison_of_firewalls_Wikipedia_html11' table
[INFO] sqlitebiter url: converted results: source=1, success=11, created-table=11
[INFO] sqlitebiter url: database path: out.sqlite
Output
$ sqlite3 out.sqlite .schema
CREATE TABLE IF NOT EXISTS '_source_info_' ("source_id" INTEGER NOT NULL, "dir_name" TEXT, "base_name" TEXT NOT NULL, "format_name" TEXT NOT NULL, "dst_table" TEXT NOT NULL, size INTEGER, mtime INTEGER);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html1' (Firewall TEXT, License TEXT, [Cost and usage limits] TEXT, OS TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html2' (Firewall TEXT, License TEXT, Cost TEXT, OS TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html3' ([Can Target:] TEXT, [Changing default policy to accept/reject (by issuing a single rule)] TEXT, [IP destination address(es)] TEXT, [IP source address(es)] TEXT, [TCP/UDP destination port(s)] TEXT, [TCP/UDP source port(s)] TEXT, [Ethernet MAC destination address] TEXT, [Ethernet MAC source address] TEXT, [Inbound firewall (ingress)] TEXT, [Outbound firewall (egress)] TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html4' ([Can:] TEXT, [work at OSI Layer 4 (stateful firewall)] TEXT, [work at OSI Layer 7 (application inspection)] TEXT, [Change TTL? (Transparent to traceroute)] TEXT, [Configure REJECT-with answer] TEXT, [DMZ (de-militarized zone) - allows for single/several hosts not to be firewalled.] TEXT, [Filter according to time of day] TEXT, [Redirect TCP/UDP ports (port forwarding)] TEXT, [Redirect IP addresses (forwarding)] TEXT, [Filter according to User Authorization] TEXT, [Traffic rate-limit / QoS] TEXT, Tarpit TEXT, Log TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html5' ([Features:] TEXT, "Configuration: GUI_ text or both modes?" TEXT, "Remote Access: Web (HTTP)_ Telnet_ SSH_ RDP_ Serial COM RS232_ ..." TEXT, [Change rules without requiring restart?] TEXT, [Ability to centrally manage all firewalls together] TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html6' ([Features:] TEXT, [Modularity: supports third-party modules to extend functionality?] TEXT, [IPS : Intrusion prevention system] TEXT, [Open-Source License?] TEXT, [supports IPv6 ?] TEXT, [Class: Home / Professional] TEXT, [Operating Systems on which it runs?] TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html7' ([Can:] TEXT, "NAT44 (static_ dynamic w/o ports_ PAT)" TEXT, "NAT64_ NPTv6" TEXT, [IDS (Intrusion Detection System)] TEXT, [VPN (Virtual Private Network)] TEXT, [AV  (Anti-Virus)] TEXT, Sniffer TEXT, [Profile selection] TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html8' ([vteFirewall software] TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html9' (A TEXT, B TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html10' (A TEXT, B TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html11' (A TEXT, B TEXT);

The attributes within the converted SQLite database may include symbols as the above. Symbols within attributes can be replaced by using --replace-symbol option. The following example shows replacing symbols with underscores.

Example
$ sqlitebiter --replace-symbol _ -q url "https://en.wikipedia.org/wiki/Comparison_of_firewalls"
Output
$ sqlite3 out.sqlite .schema
CREATE TABLE IF NOT EXISTS '_source_info_' ("source_id" INTEGER NOT NULL, "dir_name" TEXT, "base_name" TEXT NOT NULL, "format_name" TEXT NOT NULL, "dst_table" TEXT NOT NULL, size INTEGER, mtime INTEGER);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html1' (Firewall TEXT, License TEXT, "Cost_and_usage_limits" TEXT, OS TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html2' (Firewall TEXT, License TEXT, Cost TEXT, OS TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html3' ("Can_Target" TEXT, "Changing_default_policy_to_accept_reject_by_issuing_a_single_rule" TEXT, "IP_destination_address_es" TEXT, "IP_source_address_es" TEXT, "TCP_UDP_destination_port_s" TEXT, "TCP_UDP_source_port_s" TEXT, "Ethernet_MAC_destination_address" TEXT, "Ethernet_MAC_source_address" TEXT, "Inbound_firewall_ingress" TEXT, "Outbound_firewall_egress" TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html4' (Can TEXT, "work_at_OSI_Layer_4_stateful_firewall" TEXT, "work_at_OSI_Layer_7_application_inspection" TEXT, "Change_TTL_Transparent_to_traceroute" TEXT, "Configure_REJECT_with_answer" TEXT, "DMZ_de_militarized_zone_allows_for_single_several_hosts_not_to_be_firewalled" TEXT, "Filter_according_to_time_of_day" TEXT, "Redirect_TCP_UDP_ports_port_forwarding" TEXT, "Redirect_IP_addresses_forwarding" TEXT, "Filter_according_to_User_Authorization" TEXT, "Traffic_rate_limit_QoS" TEXT, Tarpit TEXT, Log TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html5' (Features TEXT, "Configuration_GUI_text_or_both_modes" TEXT, "Remote_Access_Web_HTTP_Telnet_SSH_RDP_Serial_COM_RS232" TEXT, "Change_rules_without_requiring_restart" TEXT, "Ability_to_centrally_manage_all_firewalls_together" TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html6' (Features TEXT, "Modularity_supports_third_party_modules_to_extend_functionality" TEXT, "IPS _Intrusion_prevention_system" TEXT, "Open_Source_License" TEXT, "supports_IPv6" TEXT, "Class_Home_Professional" TEXT, "Operating_Systems_on_which_it_runs" TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html7' (Can TEXT, "NAT44_static_dynamic_w_o_ports_PAT" TEXT, "NAT64_NPTv6" TEXT, "IDS_Intrusion_Detection_System" TEXT, "VPN_Virtual_Private_Network" TEXT, "AV_Anti_Virus" TEXT, Sniffer TEXT, "Profile_selection" TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html8' ("vteFirewall_software" TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html9' (A TEXT, B TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html10' (A TEXT, B TEXT);
CREATE TABLE IF NOT EXISTS 'Comparison_of_firewalls_Wikipedia_html11' (A TEXT, B TEXT);

Create SQLite database from stdin

Examples

A data format is a mandatory argument for sqlitebiter stdin subcommand:

Example
$ echo '[{"hoge": 4, "foo": "abc"}, {"hoge": 12, "foo": "xyz"}]' | sqlitebiter stdin json
[INFO] convert 'stdin' to 'json1' table
[INFO] converted results: source=1, success=1, created-table=1
[INFO] database path: out.sqlite

Command help

Usage: sqlitebiter [OPTIONS] COMMAND [ARGS]...

Options:
  -o, --output-path PATH          Output path of the SQLite database file.
                                  [default: out.sqlite]
  -a, --append                    Append table(s) to existing database.
  --add-primary-key PRIMARY_KEY_NAME
                                  Add 'PRIMARY KEY AUTOINCREMENT' column to a
                                  converted table with the specified name.
  --convert-config TEXT           [experimental] Configurations for data
                                  conversion. The option can be used only for
                                  url subcommand.
  -i, --index INDEX_ATTR          Comma separated attribute names to create
                                  indices.
  --no-type-inference             All of the columns assume as TEXT data type
                                  in creating tables.
  --type-hint-header              Use header suffixes as type hints. If there
                                  are type hints, convert columns by datatype
                                  corresponding with type hints. The following
                                  suffixes can be recognized as type hints
                                  (case insensitive): "text": TEXT datatype.
                                  "integer": INTEGER datatype. "real": REAL
                                  datatype.
  --matrix-formatting [header_aligned|trim]
                                  header_aligned: fitting table data to header
                                  columns. trim: fitting table data to minimum
                                  column size.  [default: header_aligned]
  --replace-symbol TEXT           Replace symbols in attributes.
  -v, --verbose                   Verbosity level.  [default: 0]
  --max-workers WORKERS           Specify the maximum number of workers that
                                  the command may use.  [default: 1]
  --debug                         For debug print.
  -q, --quiet                     Suppress execution log messages.
  -h, --help                      Show this message and exit.

Commands:
  completion  A helper command to setup command completion.
  configure   Configure the following application settings:
  file        Convert tabular data within CSV/Excel/HTML/JSON/Jupyter...
  gs          Convert a spreadsheet in Google Sheets to a SQLite database...
  stdin       Convert tabular data within CSV/HTML/JSON/Jupyter...
  url         Scrape tabular data from a URL and convert data to a SQLite...
  version     Show version information

For more information

More examples are available at https://sqlitebiter.rtfd.io/en/latest/pages/usage/index.html

Installation

Installation: pip (Python package manager)

pip install sqlitebiter

Installation: apt

You can install the package by apt via a Personal Package Archive (PPA):

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install sqlitebiter

Installation: dpkg (.deb package)

The following commands will download the latest .deb package from the release page, and install it.

curl -sSL https://raw.githubusercontent.com/thombashi/sqlitebiter/master/scripts/installer.sh | sudo bash

Installation: Windows

sqlitebiter can be used in Windows environments without Python installation as follows:

  1. Navigate to https://github.com/thombashi/sqlitebiter/releases
  2. Download the latest version of the sqlitebiter_windows_amd64.zip
  3. Unzip the file
  4. Execute sqlitebiter.exe in either Command Prompt or PowerShell

Installation: Windows (PowerShell)

The following commands will download the latest execution binary from the release page to the current directory.

wget https://github.com/thombashi/sqlitebiter/raw/master/scripts/get-sqlitebiter.ps1 -OutFile get-sqlitebiter.ps1
Set-ExecutionPolicy Unrestricted -Scope Process -Force; .\get-sqlitebiter.ps1

Installation: brew for macOS

$ brew tap thombashi/sqlitebiter
$ brew install sqlitebiter

Command Completion (bash/zsh)

setup command completion for bash:

    sqlitebiter completion bash >> ~/.bashrc

setup command completion for zsh:

    sqlitebiter completion zsh >> ~/.zshrc

Dependencies

Python 3.7+

Python package dependencies

Google Sheets dependencies (Optional)

Extra Python packages are required to install to use the Google Sheets feature (gs subcommand):

The extra packages can be installed with the following pip command;

$ pip install sqlitebiter[gs]

note: binary packages include these dependencies

Misc dependencies (Optional)

Dependencies other than Python packages (Optional)

  • libxml2 (faster HTML/Markdown conversion)
  • pandoc (required when converting MediaWiki files)

Documentation

https://sqlitebiter.rtfd.io/

Sponsors

ex-sponsor: Charles Becker (chasbecker) ex-sponsor: 時雨堂 (shiguredo) onetime: Dmitry Belyaev (b4tman) onetime: Arturi0 onetime: GitHub (github)

Become a sponsor

sqlitebiter's People

Contributors

brendonmiranda avatar dependabot[bot] avatar provthomas avatar sente avatar thombashi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqlitebiter's Issues

access google sheets without authentication

@rcf18 and I would like to be able to access google sheets without authentication for those sheets where "Anyone with the link can view the spreadsheet" has been set as an option.

sqlitebiter -v gs https://docs.google.com/spreadsheets/d/1Wd0RMKAMaTptZ43Bcll664HL9HtMjExrL4
AmDHCee-A/edit

Usage: sqlitebiter gs [OPTIONS] CREDENTIALS TITLE

Anyone working on enabling that as a feature yet?

Thanks!

Append data

Feature request: Love this project even as I try to debug some JSON loading. But I think it's going to be AMAZINGLY helpful. Any chance of getting an append option for data that match an existing table structure?

Unable to locate package

Describe the bug

sudo apt install sqlitebiter returns:

Unable to locate package sqlitebiter

...after adding repo

Expected behavior

sqlitebiter installs correctly

To Reproduce

Steps to reproduce the behavior:

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install sqlitebiter

Environments

Please complete the following information:

  • <past the output of sqlitebiter version subcommand>
  • Installation Method: pip / deb package / apt(PPA) / brew (choose one of these)

apt (PPA) on Linux subsystem for Windows 10
Ubuntu 20.04.1 LTS

Additional context

Output of sudo apt update looks normal, except for this:
Failed to fetch http://ppa.launchpad.net/thombashi/ppa/ubuntu/dists/focal/main/binary-amd64/Packages 404 Not Found [IP: 91.189.95.85 80]

Non able to create output, starting from a simple html page

Describe the bug

Hi, when I run

sqlitebiter url "https://gist.githubusercontent.com/aborruso/01db63cb74f0646e6bf0cb2b21b02951/raw/220c167e2fd8106f8cfea89d87239a3e8c1d9d6e/page.html"

I have this error

Traceback (most recent call last):
  File "cli.py", line 14, in <module>
  File "click/core.py", line 1137, in __call__
  File "click/core.py", line 1062, in main
  File "click/core.py", line 1668, in invoke
  File "click/core.py", line 1404, in invoke
  File "click/core.py", line 763, in invoke
  File "click/decorators.py", line 26, in new_func
  File "sqlitebiter/__main__.py", line 433, in url
  File "sqlitebiter/converter/_url.py", line 121, in convert
  File "sqlitebiter/converter/_table_creator.py", line 48, in create
  File "simplesqlite/core.py", line 1378, in create_table_from_tabledata
  File "simplesqlite/core.py", line 1727, in __create_table_from_tabledata
  File "simplesqlite/core.py", line 647, in insert_many
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 1 supplied.
[14985] Failed to execute script cli

Expected behavior

To have my sqlite db

To Reproduce

Steps to reproduce the behavior:

Simply run sqlitebiter url "https://gist.githubusercontent.com/aborruso/01db63cb74f0646e6bf0cb2b21b02951/raw/220c167e2fd8106f8cfea89d87239a3e8c1d9d6e/page.html"

Environments

Please complete the following information:

- uname: Linux
- Python version: CPython 3.8.10
- sqlitebiter version: 0.35.2
- SimpleSQLite version: not installed
- pytablereader version: not installed
  • Installation Method: deb package

Additional context

Add any other context (logs, error output, etc.) about the problem here.
(If it’s long, please paste to https://ghostbin.co/ and insert the link here.)

Invalid data json format

I tried to convert a json which I created here (https://jsoneditoronline.org/) and the application throws the following error:
invalid json data format: path=.\data.json, message='utf-8' codec can't decode byte 0xc5 in position 110: invalid continuation byte.
I am on win10, I am using sqlitebiter 0.12.0 and I attach the json file which contains Greek letters also.
data.zip

I also tried from a url (https://api.myjson.com/bins/j055h) , application returns with no error but it creates an SQLite file with 0KB size!

Support simple hierarchical JSON

Since probably most JSON files which are valuable enough to be migrated to a database contain nested arrays, this feels like an absolute must have feature.

E.g. following JSON array can't be imported properly:

[
  {
    "date": "",
    "brand": "Generic Brand",
    "title": "Some Product",
    "version": "170",
    "website": "https://products.com/234723",
    "reviews": [
      {
        "url": "https://reviews.com/1",
        "lang": "en"
      }
    ]
  },
  {
    "date": "2021",
    "brand": "Other Brand",
    "title": "Thing",
    "website": "https://things.com/1232",
    "price": "70 €",
    "reviews": [
      {
        "url": "https://reviews.com/2",
        "lang": "en"
      }
    ]
  }
]

binary packaging errors

Hey Tsuyoshi!

The sqlitebiter.exe's of v0.27.0 do not work. Seems the pkg_resource 'jsonschema' is missing.

I'm using executables from https://ci.appveyor.com/project/thombashi/sqlitebiter/builds/23301467

The output for the Python-2.7 version is:

sqlitebiter.exe --version
Traceback (most recent call last):
  File "cli.py", line 10, in <module>
  File "c:\users\appveyor\appdata\local\temp\1\pip-install-khe1ut\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
  File "sqlitebiter\sqlitebiter.py", line 19, in <module>
  File "c:\users\appveyor\appdata\local\temp\1\pip-install-khe1ut\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
  File "site-packages\pytablereader\__init__.py", line 28, in <module>
  File "c:\users\appveyor\appdata\local\temp\1\pip-install-khe1ut\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
  File "site-packages\pytablereader\json\core.py", line 22, in <module>
  File "c:\users\appveyor\appdata\local\temp\1\pip-install-khe1ut\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
  File "site-packages\pytablereader\json\formatter.py", line 11, in <module>
  File "c:\users\appveyor\appdata\local\temp\1\pip-install-khe1ut\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
  File "site-packages\jsonschema\__init__.py", line 33, in <module>
  File "site-packages\pkg_resources\__init__.py", line 472, in get_distribution
  File "site-packages\pkg_resources\__init__.py", line 344, in get_provider
  File "site-packages\pkg_resources\__init__.py", line 892, in require
  File "site-packages\pkg_resources\__init__.py", line 778, in resolve
pkg_resources.DistributionNotFound: The 'jsonschema' distribution was not found and is required by the application
[14112] Failed to execute script cli

The output for the Python-3.7 version is:

sqlitebiter.exe --version
Traceback (most recent call last):
  File "cli.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37-x64\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "sqlitebiter\sqlitebiter.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37-x64\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\pytablereader\__init__.py", line 28, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37-x64\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\pytablereader\json\core.py", line 22, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37-x64\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\pytablereader\json\formatter.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37-x64\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\jsonschema\__init__.py", line 33, in <module>
  File "site-packages\pkg_resources\__init__.py", line 479, in get_distribution
  File "site-packages\pkg_resources\__init__.py", line 355, in get_provider
  File "site-packages\pkg_resources\__init__.py", line 898, in require
  File "site-packages\pkg_resources\__init__.py", line 784, in resolve
pkg_resources.DistributionNotFound: The 'jsonschema' distribution was not found and is required by the application
[14896] Failed to execute script cli

I'm not sure, when this error was introduced.
I switched back to v0.23.8, which works for me.

Please test the version output of the executable on Appveyor to avoid this (maybe test_script: C:\projects\sqlitebiter\dist\sqlitebiter.exe --version is enough; but i'm not sure, if this fails the build, when execution of the exe fails).

Regards, Jens

feature request: add option to disable type inference when parsing the input

Hi,
reading this reply I have discovered that sqlitebiter do field type inference, when collect data starting from a webpage.

Now there is --convert-config option that enables to set field type for every field.

I think that for some complex source could be long and boring to set field type for a lot of fields.
A solution could be to add a -I parameter to disable type inference when parsing the input, and have all field type set as text.

Thank you

Flatten JSON

Flatten JSON which has JSON schema format currently not supported before converting.

Poll: #89

Create a SQLite database from URL in append

First of all, thank you @thombashi , this is a great project!

I want to create a db starting from https://si.siciliafse1420.it/elencobeneficiari?page=1, and than page after page - until page 237 - I want to append all the tables to my db.

sqlitebiter using "-a" creates one db and 237 tables. Is it possible to append every source table to only one destination table (the structure is the same)?

Thank you

Conversion fails without errors on JSON

Even when using the exact sample provided in the docs.

{
    "type": "object",
    "additionalProperties": {
        "type": "array",
        "items": {
            "type": "object",
            "additionalProperties": {
                "anyOf": [
                    {"type": "string"},
                    {"type": "number"},
                    {"type": "null"}
                ]
            }
        }
    }
}

Feature: support duplicated column name from excel files

Given that row 1 in a excel file defines columns' name, it is valid to have multiple columns with the same name in excel.

Could sqlitebiter file xxxxx.xls with such a file could handle the case instead of raising the sqlite3.OperationalError: duplicate column name: COUNTRY error? Maybe by using a suffix _2 for the second column with a given name?

Conversion fails for Excel sheets that have a single quote in a table header

I have a spreadsheet with a header that has a single quote in it:

Don't Do This
1 2 3
3 2 1

It fails like this:

> sqlitebiter file Woo.xlsx                                                                                                                      
convert 'Woo.xlsx' to 'Sheet1' table                                                                                                             
Traceback (most recent call last):                                                                                                               
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main                                                                              
    "__main__", fname, loader, pkg_name)                                                                                                         
  File "c:\python27\lib\runpy.py", line 72, in _run_code                                                                                         
    exec code in run_globals                                                                                                                     
  File "C:\Python27\Scripts\sqlitebiter.exe\__main__.py", line 9, in <module>                                                                    
  File "c:\python27\lib\site-packages\click\core.py", line 716, in __call__                                                                      
    return self.main(*args, **kwargs)                                                                                                            
  File "c:\python27\lib\site-packages\click\core.py", line 696, in main                                                                          
    rv = self.invoke(ctx)                                                                                                                        
  File "c:\python27\lib\site-packages\click\core.py", line 1060, in invoke                                                                       
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                      
  File "c:\python27\lib\site-packages\click\core.py", line 889, in invoke                                                                        
    return ctx.invoke(self.callback, **ctx.params)                                                                                               
  File "c:\python27\lib\site-packages\click\core.py", line 534, in invoke                                                                        
    return callback(*args, **kwargs)                                                                                                             
  File "c:\python27\lib\site-packages\sqlitebiter\sqlitebiter.py", line 99, in file                                                              
    con.create_table_from_tabledata(tabledata)                                                                                                   
  File "c:\python27\lib\site-packages\simplesqlite\core.py", line 979, in create_table_from_tabledata                                            
    data_matrix=tabledata.record_list)                                                                                                           
  File "c:\python27\lib\site-packages\simplesqlite\core.py", line 960, in create_table_with_data                                                 
    self.create_table(table_name, attr_description_list)                                                                                         
  File "c:\python27\lib\site-packages\simplesqlite\core.py", line 874, in create_table                                                           
    if self.execute_query(query, logging.getLogger().findCaller()) is None:                                                                      
  File "c:\python27\lib\site-packages\simplesqlite\core.py", line 237, in execute_query                                                          
    raise sqlite3.OperationalError(os.linesep.join(message_list))                                                                                
sqlite3.OperationalError: failed to execute query at c:\python27\lib\site-packages\simplesqlite\core.py(979) create_table_from_tabledata         
  - query: CREATE TABLE IF NOT EXISTS 'Sheet1' ('Don't' REAL, 'Do ' REAL, 'This' REAL)                                                           
  - msg:   unrecognized token: "' REAL)"                                                                                                         
  - db:    C:\Users\me\Projects\import\out.sqlite        

Convert excel DATE to sqlite DATE

sqlitebiter is a very efficient xlsx conversion sqlite tool.
But Excel DATE type will be converted to INTEGER,
jt_2020-12-26_15-28-57
Before each conversion to SQLite, the Excel date should be converted into text first, and then converted with sqlitebiter.

Is there any option to automatically convert the DATE to a normal value?
For example: 1900/1/1 + 44191 day + 1 day = 2020/12/26

Crash with strings that may look like a scientific notation

When the table has values that are strings but look like scientific notation, like 45e76582 sqlitebitter crashes. For example, use the following HTML without --no-type-inference flag:

<table>
    <caption>example</caption>
  <tr>
    <th>value</th>
  </tr>
  <tr>
    <td>45e76582</td>
  </tr>
</table>

It also crashes when using the flag --no-type-inference, but wasn't able to create a minimal example for this crash.

Feature Request: Import Jupyter notebooks

I've been looking for efficient ways to help users search Jupyter notebooks, and storing them in SQLIte may be one way to support this.

The Jupyter notebook .ipynb document format is a JSON document (specification), but only some of the elements are meaningful to users. For example, Jupyter notebooks include the notion of "typed" cells, such as markdown or code cells. Storing the contents of these cells, along the type of the cell and the cell order in a notebook, could provide one way of supporting search over them in a meaningful way.

More generally, indexing a Jupyter documents could be seen as an instance of only storing a subset of a JSON document in a structured way and as such provide a test case for a "parsed" JSON import?

Importing array of JSON fails

If I try to import the following JSON, everything works as expected:

{
  "tenantId": "b75c12e6-6b42-4d9f-a67d-fd36aad933d3",
  "objectType": "BATCH_RULE",
  "objectId": "60d03060-0bd7-48d2-818a-d1cab7c48f78",
  "objectName": "MyBatchRule14",
  "correlationId": "e9677743-740c-4797-8ab3-ad596c833c05",
  "executionTimestamp": "2020-03-03T06:00:01.965Z",
  "status": "SUCCESS",
  "error": {
    "code": "",
    "message": "",
    "detail": ""
  },
  "source": {
    "objectType": "",
    "objectId": "",
    "objectName": ""
  },
  "executionParams": [],
  "results": [
    {
      "resultName": "Things",
      "resultValue": "1"
    },
    {
      "resultName": "ThingsMetCondition",
      "resultValue": "0"
    }
  ]
}
$ sqlitebiter -v file test.json
[INFO] convert '/Users/i831533/test.json' to 'error (key, value)' table
[INFO] convert '/Users/i831533/test.json' to 'source (key, value)' table
[INFO] convert '/Users/i831533/test.json' to 'results (resultName, resultValue)' table
[INFO] convert '/Users/i831533/test.json' to 'root (key, value)' table
[INFO] converted results: source=1, success=4, created-table=4
[INFO] database path: out.sqlite

However, as soon as I try to make it in to an array, the import fails:

[
  {
    "tenantId": "b75c12e6-6b42-4d9f-a67d-fd36aad933d3",
    "objectType": "BATCH_RULE",
    "objectId": "60d03060-0bd7-48d2-818a-d1cab7c48f78",
    "objectName": "MyBatchRule14",
    "correlationId": "e9677743-740c-4797-8ab3-ad596c833c05",
    "executionTimestamp": "2020-03-03T06:00:01.965Z",
    "status": "SUCCESS",
    "error": {
      "code": "",
      "message": "",
      "detail": ""
    },
    "source": {
      "objectType": "",
      "objectId": "",
      "objectName": ""
    },
    "executionParams": [],
    "results": [
      {
        "resultName": "Things",
        "resultValue": "1"
      },
      {
        "resultName": "ThingsMetCondition",
        "resultValue": "0"
      }
    ]
  }
]
$ sqlitebiter -v file test.json
[WARNING] convertible table not found in test.json
[INFO] converted results: source=0

Better default name for database file

The default name out.sqlite is quite generic:

$ sqlitebiter file test.csv
[INFO] convert 'test.csv' to 'test' table
[INFO] converted results: source=1, success=1, created-table=0
[INFO] database path: out.sqlite

Instead, the name should be based on the input filename.

e.g. test.sqlite

What are the appropriate Google Sheets/Drive/API permissions needed?

Regardless of the permissions I set, sqlitebiter complains that it can't find any google sheet that I reference. I've verified the credentials, and even see the google drive list API commands running successfully in the Google API dashboards. I've tried sharing out the sheets, creating new sheets, etc, but it always complains OpenError: spreadsheet 'xxxxxx' not found. Downloading a CSV from GS and importing it that way works as expected.

Latest version of sqlitebiter (0.29.2), all dependencies installed, etc.

transfer .csv file to sqlite wrong

I have a xx.csv file like this:

smokey,Linux 3.0-ARCH,x86
12345678901,12345 1234567890123,123
12345678901,1234567890123456789,12345
11 bytes,19 bytes,5 byt
test line:,"Some ""comma, quote""",foo
skylight,Linux 3.0-ARCH,x86
polaris,Linux 3.0-ARCH,amd64
asgard,Windows 6.1.7600,amd64
galileo,Windows 6.2.8102,x86
kepler,Windows 6.2.8123,amd64
wrfbox,Windows 6.2.8133,amd64

I get the out.sqlite file when running "sqlitebiter file xx.csv" command.
But when i select from the table, i get the following columns:

12345678901|12345 1234567890123|123
12345678901|1234567890123456789|12345
11 bytes|19 bytes|5 byt
test line:|Some "comma, quote|foo
skylight|Linux 3.0-ARCH|x86
polaris|Linux 3.0-ARCH|amd64
asgard|Windows 6.1.7600|amd64
galileo|Windows 6.2.8102|x86
kepler|Windows 6.2.8123|amd64
wrfbox|Windows 6.2.8133|amd64

The quote has not transformed correctly at line:
test line:,"Some ""comma, quote""",foo
missing right quote in sqlite table.

AttributeError: 'TableFileLoaderFactory' object has no attribute 'create_from_file_path'

When first running the script I got this error:

qlitebiter file example.json -o example.sqlite             
Traceback (most recent call last):
  File "/usr/local/bin/sqlitebiter", line 11, in <module>
    sys.exit(cmd())
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/sqlitebiter/sqlitebiter.py", line 97, in file
    loader = loader_factory.create_from_file_path()
AttributeError: 'TableFileLoaderFactory' object has no attribute 'create_from_file_path'

I changed line 97 in /usr/local/lib/python3.5/dist-packages/sqlitebiter/sqlitebiter.py from:
loader = loader_factory.create_from_file_path()
to:
loader = loader_factory.create_from_path()
... and it worked again

ODS Support

This is a very nice library with support for far-flung formats ranging from xls to csv. But it would really be great to also have LibreOffice Calc ODS support.

Unable to use named pipe with sqlitebiter file

I'm trying to create SQLite from a large (multi-gigabytes) gziped JSONL file.

I tried to create a named pipe (mkfifo) , gzcat my file to the named pipe and use it as input to sqliter file, but it gives me "not a file" error.

Am I doing something wrong, or you do not support named pipes, is there a good reason?

Android/Termux Lacks Semaphores (sem_open) - Fatal Error

Hi!

Installing on Android/Termux seems to go just fine but when trying to convert JSON data to sqlite, there is a fatal error because Android doesn't have a functioning sem_open method for threading (semaphores)... see trace below and see Python Issue#3770. sqlite3 compiles and runs just fine as do most other python modules...

I haven't had a chance to really look through the trace yet to see where the multiprocessing module is getting pulled into the mix.

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/synchronize.py", line 28, in <module>
    from _multiprocessing import SemLock, sem_unlink
ImportError: cannot import name 'SemLock' from '_multiprocessing' (/data/data/com.termux/files/usr/lib/python3.8/lib-dynload/_multiprocessing.cpython-38.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/dataproperty/_extractor.py", line 556, in __to_dp_matrix_mt
    with futures.ProcessPoolExecutor(self.max_workers) as executor:
  File "/data/data/com.termux/files/usr/lib/python3.8/concurrent/futures/process.py", line 555, in __init__
    self._call_queue = _SafeQueue(
  File "/data/data/com.termux/files/usr/lib/python3.8/concurrent/futures/process.py", line 165, in __init__
    super().__init__(max_size, ctx=ctx)
  File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/queues.py", line 42, in __init__
    self._rlock = ctx.Lock()
  File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/context.py", line 67, in Lock
    from .synchronize import Lock
  File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/synchronize.py", line 30, in <module>
    raise ImportError("This platform lacks a functioning sem_open" +
ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/sqlitebiter", line 8, in <module>
    sys.exit(cmd())
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/sqlitebiter/sqlitebiter.py", line 288, in file
    converter.convert(file_path)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/sqlitebiter/subcommand/_file.py", line 104, in convert
    self.__convert(file_path, source_info_record_base)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/sqlitebiter/subcommand/_file.py", line 143, in __convert
    self._table_creator.create(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/sqlitebiter/_table_creator.py", line 27, in create
    con_mem.create_table_from_tabledata(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/simplesqlite/core.py", line 1310, in create_table_from_tabledata
    self.__create_table_from_tabledata(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/simplesqlite/core.py", line 1660, in __create_table_from_tabledata
    self.__extract_attr_descs_from_tabledata(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/simplesqlite/core.py", line 1603, in __extract_attr_descs_from_tabledata
    six.iteritems(self.__extract_col_type_from_tabledata(table_data))
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/simplesqlite/core.py", line 1633, in __extract_col_type_from_tabledata
    for col_idx, col_dp in enumerate(table_data.column_dp_list)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/tabledata/_core.py", line 145, in column_dp_list
    return self.__dp_extractor.to_column_dp_list(self.value_dp_matrix)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/tabledata/_core.py", line 133, in value_dp_matrix
    self.__value_dp_matrix = self.__dp_extractor.to_dp_matrix(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/dataproperty/_extractor.py", line 437, in to_dp_matrix
    return self.__to_dp_matrix_mt(value_matrix)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/dataproperty/_extractor.py", line 574, in __to_dp_matrix_mt
    executor.shutdown()
UnboundLocalError: local variable 'executor' referenced before assignment

Error: no such option: --multiprocessing-fork

Hi, on Windows 10 x64 using the binary I get the following:

sqlitebiter.exe file test.csv
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Error: no such option: --multiprocessing-fork
Traceback (most recent call last):
File "cli.py", line 12, in
File "site-packages\click\core.py", line 722, in call
File "site-packages\click\core.py", line 697, in main
File "site-packages\click\core.py", line 1066, in invoke
File "site-packages\click\core.py", line 895, in invoke
File "site-packages\click\core.py", line 535, in invoke
File "site-packages\click\decorators.py", line 17, in new_func
File "sqlitebiter\sqlitebiter.py", line 280, in file
File "site-packages\pytablereader\csv\formatter.py", line 43, in to_table_data
File "site-packages\tabledata_core.py", line 123, in init
File "site-packages\dataproperty_extractor.py", line 358, in to_dp_matrix
File "site-packages\dataproperty_extractor.py", line 455, in __to_dp_matrix_mt
File "concurrent\futures_base.py", line 425, in result
File "concurrent\futures_base.py", line 384, in __get_result
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
[9248] Failed to execute script cli
Exception ignored in: <bound method SimpleSQLite.del of <simplesqlite.core.SimpleSQLite object at 0x0000021B20EAE2E8>>
Traceback (most recent call last):
File "site-packages\simplesqlite\core.py", line 109, in del
File "site-packages\simplesqlite\core.py", line 1375, in close
File "site-packages\simplesqlite\core.py", line 169, in check_connection
File "site-packages\typepy_function.py", line 24, in is_null_string
ImportError: sys.meta_path is None, Python is likely shutting down

What am I doing wrong?

Why is sqlitebiter rejecting this data as invalid json data format?

Hi,

I'm trying to figure out why sqlitebiter doesn't like the json I am passing it. I've tried running it through jq, but that doesn't seem to help. I get the invalid json data format error with a message of inconvertible JSON schema.

Below is the json I'm trying to use:
``{
"name":"Zendesk Chat",
"slug":"zopim-live-chat",
"version":"1.4.12",
"author":"<a href="http://www.zendesk.com/chat?iref=wp_plugin\">Zendesk",
"author_profile":"https://profiles.wordpress.org/bencxr",
"requires":"3.1",
"tested":"4.7.10",
"requires_php":false,
"compatibility":[

],
"rating":80,
"ratings":{
"5":18,
"4":1,
"3":2,
"2":1,
"1":5
},
"num_ratings":27,
"support_threads":1,
"support_threads_resolved":0,
"downloaded":925716,
"last_updated":"2017-12-01 6:22am GMT",
"added":"2010-01-20",
"homepage":"http://www.zendesk.com/chat?iref=wp_plugin",
"short_description":"Zendesk Chat (previously Zopim) lets you monitor and chat with visitors surfing your store in real-time. Impress them personally and ease them into th …",
"download_link":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.12.zip",
"screenshots":{
"4":{
"src":"https://ps.w.org/zopim-live-chat/trunk/screenshot-4.png?rev=1779235",
"caption":"Dashboard View - Open new browser tab"
},
"3":{
"src":"https://ps.w.org/zopim-live-chat/trunk/screenshot-3.png?rev=1779235",
"caption":"Account Configuration - Linked Up with Launch Dashboard"
},
"5":{
"src":"https://ps.w.org/zopim-live-chat/trunk/screenshot-5.png?rev=1779235",
"caption":"Widget Customization from Dashboard"
},
"1":{
"src":"https://ps.w.org/zopim-live-chat/trunk/screenshot-1.png?rev=1779235",
"caption":"Chat window on your website - active chat"
},
"2":{
"src":"https://ps.w.org/zopim-live-chat/trunk/screenshot-2.png?rev=1779235",
"caption":"Account Configuration - Link Up"
}
},
"tags":{
"chat":"chat",
"chat-online":"chat online",
"contact-plugin":"contact plugin",
"contact-us":"contact us",
"customer-support":"customer support"
},
"versions":{
"0.6.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.0.6.1.zip",
"0.7":"https://downloads.wordpress.org/plugin/zopim-live-chat.0.7.zip",
"1.0":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.zip",
"1.0.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.1.zip",
"1.0.2":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.2.zip",
"1.0.3":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.3.zip",
"1.0.4":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.4.zip",
"1.0.5":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.5.zip",
"1.0.6":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.6.zip",
"1.0.7":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.0.7.zip",
"1.1.0":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.1.0.zip",
"1.1.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.1.1.zip",
"1.1.2":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.1.2.zip",
"1.1.3":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.1.3.zip",
"1.2.0":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.0.zip",
"1.2.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.1.zip",
"1.2.2":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.2.zip",
"1.2.5":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.5.zip",
"1.2.6":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.6.zip",
"1.2.7":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.7.zip",
"1.2.8":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.8.zip",
"1.2.9":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.2.9.zip",
"1.3.0":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.0.zip",
"1.3.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.1.zip",
"1.3.2":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.2.zip",
"1.3.3":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.3.zip",
"1.3.4":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.4.zip",
"1.3.5":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.5.zip",
"1.3.6":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.6.zip",
"1.3.7":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.7.zip",
"1.3.8":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.8.zip",
"1.3.9":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.3.9.zip",
"1.4.0":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.0.zip",
"1.4.1":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.1.zip",
"1.4.10":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.10.zip",
"1.4.11":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.11.zip",
"1.4.12":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.12.zip",
"1.4.2":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.2.zip",
"1.4.3":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.3.zip",
"1.4.4":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.4.zip",
"1.4.5":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.5.zip",
"1.4.6":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.6.zip",
"1.4.7":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.7.zip",
"1.4.8":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.8.zip",
"1.4.9":"https://downloads.wordpress.org/plugin/zopim-live-chat.1.4.9.zip",
"trunk":"https://downloads.wordpress.org/plugin/zopim-live-chat.zip"
},
"donate_link":""
}``

Trying to connect to Google Sheet

my line: sqlitebiter -o db.sqlite3 gs client_secret.json FA

Error: 'Expected', client.SERVICE_ACCOUNT)
ValueError: ('Unexpected credentials type', None, 'Expected', 'service_account')

Thanks!

json to sqlLite Error

{"stage":"1","house_profile_data":{"area_land":"873.00","heating_type":"2","wall_material":"1","chute_count":"0","cadastral_numbers":{"item":{"cadastral_number":"01:08:0506021:36","id":"1015511"}},"communal_services":{"item":[{"volumes_report":{},"type":"5","supplied_via_management_organization":"false","is_default":"true","id":"9387250"},{"volumes_report":{},"type":"4","is_default":"true","supplied_via_management_organization":"false","id":"9387271"},{"id":"9387273","volumes_report":{},"type":"6","is_default":"true","supplied_via_management_organization":"false"},{"is_default":"true","supplied_via_management_organization":"false","volumes_report":{},"id":"9387293","type":"2"},{"supplied_via_management_organization":"false","volumes_report":{},"type":"1","is_default":"true","id":"9387311"},{"id":"9387322","volumes_report":{},"supplied_via_management_organization":"false","type":"3","is_default":"true"}]},"electrical_type":"2","cold_water_type":"2","floor_type":"1","energy_efficiency":"1","hot_water_type":"1","sewerage_type":"2","area_total":"397.20","is_alarm":"false","elevators_count":"0","area_basement":"0.00","electrical_entries_count":"1","area_non_residential":"0.00","gas_type":"2","metering_devices":{"item":[{"is_default":"true","id":"10641099","communal_resource_type":"1"},{"is_default":"true","id":"10641105","communal_resource_type":"2"},{"id":"10641117","is_default":"true","communal_resource_type":"3"},{"is_default":"true","communal_resource_type":"4","id":"10641125"},{"id":"10641156","is_default":"true","communal_resource_type":"5"},{"is_default":"true","id":"10641160","communal_resource_type":"6"}]},"flats_count":"8","report":{"common":{}},"entrance_count":"1","floor_count_max":"2","house_type":"1","area_residential":"367.20","exploitation_start_year":"1968","project_type":"q"},"house_id":"6472563","full_address":{"region_short_name":"Респ","city1_code":"0100000100000","region_guid":"d8327a56-80de-4df2-815c-4f6ab1224c50","street_formal_name":"Герцена","region_code":"0100000000000","street_guid":"3869993c-24de-4d4f-b808-72650498c31e","block":"А","city1_formal_name":"Майкоп","house_number":"104","houseguid":"b77728f6-8f8b-46c0-f01e-904e1d6eea7e","street_short_name":"ул","city1_guid":"8cfbe842-e803-49ca-9347-1ef90481dd98","region_formal_name":"Адыгея","city1_short_name":"г","street_code":"01000001000003600"},"last_update":"2015-05-22T20:42:02+03:00"}

➜ sqlitebiter -v file 8937415.json
Traceback (most recent call last):
File "cli.py", line 14, in
File "click/core.py", line 829, in call
File "click/core.py", line 782, in main
File "click/core.py", line 1259, in invoke
File "click/core.py", line 1066, in invoke
File "click/core.py", line 610, in invoke
File "click/decorators.py", line 21, in new_func
File "sqlitebiter/main.py", line 275, in file
File "sqlitebiter/converter/_file.py", line 98, in convert
File "sqlitebiter/converter/_file.py", line 138, in __convert
File "sqlitebiter/converter/_table_creator.py", line 49, in create
File "simplesqlite/core.py", line 1375, in create_table_from_tabledata
File "simplesqlite/core.py", line 1732, in __create_table_from_tabledata
File "simplesqlite/core.py", line 648, in insert_many
sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.
[42421] Failed to execute script cli

Unable to convert csv file in cp1251 encoding

System:
MacOSX Hight Sierra 10.13.6 (17G65)

Command:
sqlitebiter -o file.sqlite --debug file -f csv --encoding cp1251 file.csv

File link:
http://www.drlz.com.ua/ibp/zvity.nsf/all/zvit/$file/reestr.csv

Log:
[DEBUG] SimpleSQLie: connect to a SQLite database: path='reestr.sqlite', mode=w
[DEBUG] SimpleSQLie: commit: path='/Users/martiush/PharmacyTracker/PharmacyTracker/reestr.sqlite'
[DEBUG] SimpleSQLie: CREATE TABLE IF NOT EXISTS 'source_info' ("source_id" INTEGER NOT NULL, "dir_name" TEXT, "base_name" TEXT NOT NULL, "format_name" TEXT NOT NULL, "dst_table" TEXT NOT NULL, size INTEGER, mtime INTEGER)
[DEBUG] sqlitebiter file: converting 'reestr.csv'
[DEBUG] pytablereader: TableFileLoaderFactory.create_from_format_name: name=csv
[DEBUG] pytablereader: loading file: format=csv, path=reestr.csv, encoding=cp1251
[ERROR] sqlitebiter file: DataError: invalid csv data: path=reestr.csv, message=',' expected after '"'
[WARNING] sqlitebiter file: table not found in reestr.csv
[DEBUG] sqlitebiter file: ----- sqlitebiter completed -----
[INFO] sqlitebiter file: converted results: source=0, fail=1
[DEBUG] sqlitebiter file: database path: reestr.sqlite
[DEBUG] SimpleSQLie: close connection to a SQLite database: path='/Users/martiush/PharmacyTracker/PharmacyTracker/reestr.sqlite'
[DEBUG] SimpleSQLie: commit: path='/Users/martiush/PharmacyTracker/PharmacyTracker/reestr.sqlite'

Only 1000 lines

I am trying to insert a large json file to SQLite, but only the first 1000 get into the DB.

SQL table name cannot start with numeric?

What happens?

I met a bug when I try to convert the following json into sqlite file.

{
"2018Asset": [
{
"RANK": "1",
"id": "item_entertainment_18_212",
"count": "1billion"
}
]
}

What were you expecting to happen?

Convert succeed.

What are the steps to reproduce this issue?

command: sqlitebiter -o 'test.sqlite' file 'test.json'

Any logs, error output, etc?

I turn on the debug mode.
DEBUG | simplesqlite.core:create_table:1261 - CREATE TABLE IF NOT EXISTS '2018Asset' (RANK INTEGER, id TEXT, count TEXT)

Environments

  • **Operating System: macos mojave 10.14.6
  • Python Version: Python 3.7
  • **sqlitebiter Version: v0.31.0
  • **Installation Method: pip

Any other comments?

After detecting the table name starting with the number, the command should be 'CREATE TABLE IF NOT EXISTS [2018Asset] ...' instead of 'CREATE TABLE IF NOT EXISTS 2018Asset ...'.
We can escape the table's name by enclosing it with []:

Force Data Types (CSV)

Hello -

Really like the product, but having one problem, given some tables that I'm converting.

Is there no way to force a data type (say, TEXT instead of INTEGER) in a CSV file? I can switch to JSON, if that input format allows data type assignment.

Any suggestions would be much appreciated!

Best ~
Cliff

Retain leading zeros when converting text or --no-type-inference

Describe the bug

A clear and concise description of what the bug is.
Value tokens like 0003530043 and 00126 are converted to text without their leading zeros.

Expected behavior

Using CLI option --no-type-inference or --type-hint-header with a column that hints text, then the value 0003530043 should be converted as 0003530043 rather than 3530043.

To Reproduce

Steps to reproduce the behavior:

  1. Given this CSV called zero.csv:
column1, column2-text
123, 0123
0123, 123
123, 0123
  1. And the CLI: sqlitebiter --type-hint-header -o zero.sqlite file zero.csv
  2. Then after sqlite3 zero.sqlite:
.header on;
select * from zero;
  1. I expect you will see:
column1|column2-text
123|123
123|123
123|123
  1. Verify the table's structure:
CREATE TABLE IF NOT EXISTS 'zero'([column1] INTEGER, [column2-text] TEXT);

Environments

Please complete the following information:

  • uname: Darwin the-admiralty 18.7.0 x86_64

  • CPython version: 3.7.5

  • sqlitebiter version: not installed

  • SimpleSQLite version: not installed

  • pytablereader version: not installed

  • Installation Method: brew

Additional context

Add any other context (logs, error output, etc.) about the problem here.
(If it’s long, please paste to https://ghostbin.co/ and insert the link here.)

Show which part of input cause error

When I try to create sqlite from json and not using --no-type-inference, I got OverflowError like this

Traceback (most recent call last):
File "cli.py", line 14, in <module>
File "click/core.py", line 764, in __call__
File "click/core.py", line 717, in main
File "click/core.py", line 1137, in invoke
File "click/core.py", line 956, in invoke
File "click/core.py", line 555, in invoke
File "click/decorators.py", line 17, in new_func
File "sqlitebiter/sqlitebiter.py", line 271, in file
File "sqlitebiter/subcommand/_file.py", line 100, in convert
File "sqlitebiter/subcommand/_file.py", line 140, in __convert
File "sqlitebiter/_table_creator.py", line 27, in create
File "simplesqlite/core.py", line 1297, in create_table_from_tabledata
File "simplesqlite/core.py", line 1656, in __create_table_from_tabledata
File "simplesqlite/core.py", line 586, in insert_many
OverflowError: Python int too large to convert to SQLite INTEGER
[49281] Failed to execute script cli

The problem is I don't know which part or which line from input file cause the error
So its hard to edit my input file if it contains thousands or millions line in them
Is it possible for sqlitebiter to show which part cause error so user can check the input?

---edit to follow issue template---

What happens?

sqlitebiter shown error when I try to convert invalid json file, but the error is not verbose enough to know which line from input cause this error

What were you expecting to happen?

sqlitebiter shown error message containing information that the input is invalid on line XX

What are the steps to reproduce this issue?

  1. User run command sqlitebiter file example.json

Any logs, error output, etc?

Error output here: https://ghostbin.co/paste/o4cdm

Environments

  • Operating System: macOS Catalina 10.15.3
  • Python Version: Python 3.7.6
  • sqlitebiter Version: 0.29.2
  • Installation Method: brew for macOS

sqlite3.OperationalError: duplicate column name

On Ubuntu 16.04 (both a "real" install and in Bash in Ubuntu on Windows 10) I get the following error, which appears to be due to having column names with non-alphanumeric characters. In this case I have columns "ABCD>8.5" and "ABCD<8.5". I'm not sure if this is a problem with sqlitebiter, simplesqlite or something else?

sqlitebiter file complicated.xlsx
Traceback (most recent call last):
File "site-packages/simplesqlite/core.py", line 259, in execute_query
sqlite3.OperationalError: duplicate column name: ABCD85

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "cli.py", line 12, in
File "site-packages/click/core.py", line 722, in call
File "site-packages/click/core.py", line 697, in main
File "site-packages/click/core.py", line 1066, in invoke
File "site-packages/click/core.py", line 895, in invoke
File "site-packages/click/core.py", line 535, in invoke
File "site-packages/click/decorators.py", line 17, in new_func
File "sqlitebiter/sqlitebiter.py", line 286, in file
File "sqlitebiter/_table_creator.py", line 22, in create
File "site-packages/simplesqlite/core.py", line 1219, in create_table_from_tabledata
File "site-packages/simplesqlite/core.py", line 1533, in __create_table_from_tabledata
File "site-packages/simplesqlite/core.py", line 1114, in create_table
File "site-packages/simplesqlite/core.py", line 270, in execute_query
simplesqlite.error.OperationalError
[144] Failed to execute script cli

decode utf8 error

Env:x64 win7, python3.6.2

I used 'sqlitebiter file test.json -o test.sqlite', the test.json is encoded as utf-8 without bom, but I get the following error:

[ERROR] sqlitebiter file: invalid json data format: path=test.json, message='gbk' codec can't decode byte 0xa6 in position 336: illegal multibyte sequence

Getting "codec can't decode byte ..."

I am converting a tsv file which is in UTF-8.

I am using the "file" subcommand to read from the tsv file.

I get the error message:

[ERROR] DataError: invalid tsv data: path=ads_multi_all_dedupe_gen_dedupe.tsv, message='charmap' codec can't decode byte 0x8f in position 3956: character maps to <undefined>

This TSV file can be read into pandas or by myself without any problem at all when the file is read using open(filename, "rt", encoding="utf-8").
Since UTF-8 is mostly the standard for any text file these days, I would have assumed that it would work for a tsv file (which is intrinsically a text file).

Oddly, there seems to be no command line option to specify the encoding of the input file.

Am I missing something fundamental here?

EXCEL with images

My EXCEL spreadsheet has some images (.jpg) in some cells. I was hoping to be able to use sqlitebiter to convert the spreadsheet to an SQLITE database, since SQLITE3 handles images in cells properly (using BLOBs). However:

sqlitebiter -o  Test.db file "Test.xlsx"
[WARNING] sqlitebiter file: convertible table not found in Test_shareability.xlsx
[INFO] sqlitebiter file: converted results: source=0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.