Skip to main content

Generate a Sqlite3 database from a Office Open XML file.

Project description

Latest PyPI version GitHub license https://codecov.io/gh/Xgalan/xlsx2sqlite/branch/compat_py3.6-3.7/graph/badge.svg?token=R22KYIQ2UO

Generate a Sqlite3 database from a Office Open XML file. Read the xlsx2sqlite documentation.

Usage

First create a .INI config file that you will pass as an argument to the xlsx2sqlite command line tool. This will serve as a model to import data from the .xlsx file.

The INI file must contains this section:

  • PATHS

Optional sections, see below:

  • EXCLUDE

Example of a configuration:

[PATHS]
; declare the paths of the files to be read.
root_path = baserootpath/
xlsx_file = %(root_path)s/exampletoimport.xlsx
db_file = %(root_path)s/databasename.db
db_url = sqlite:///%(db_file)s
sql_views = %(root_path)s/views

; declare to import a worksheet like this :

; name of the worksheet to import
[SheetName1]
; comma-separated list of the columns to import
columns = Col1,Col2,Col3
; composite primary key is supported:
primary_key = Col1,Col2

[SheetName2]
    ; valid model keywords are:
    columns = Col1,Col2
    primary_key = id
    unique = Col2
    not_null = Col2
    ; add if the row with the header is not the first row of the worksheet
    header = 2

Optional “exclude” section, use if you don’t want to import some section of the ini file, this is useful in example for co-exist with some other configuration file.

[EXCLUDE]
    sections = SECTION1,section2,etc. ; use a list of comma-separated values.

Installation

Install the release from PyPI:

$ pip install xlsx2sqlite

Installing from source, a virtualenv is recommended:

$ pip install --editable .

Requirements

xlsx2sqlite is powered by Click and Tablib.

Compatibility

xlsx2sqlite is compatible with Python 3.7+.

Licence

GPLv3

Authors

xlsx2sqlite was written by Erik Mascheri.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlsx2sqlite-0.4.6.tar.gz (32.1 kB view hashes)

Uploaded Source

Built Distribution

xlsx2sqlite-0.4.6-py3-none-any.whl (36.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page