Skip to main content

SQL to Excel converter

https://img.shields.io/pypi/v/sqlexceller.svg https://img.shields.io/pypi/pyversions/sqlexceller.svg https://img.shields.io/:license-apache-blue.svg

Command line program that executes SQL queries and stores results in Excel files

  • Free software: Apache Software License 2.0

Features

  • Support for PostgreSQL, MySQL, Oracle, MSSQL, and SQLite

  • Accepts multiple SQL query files

  • Each SQL query will be written into a different sheet

  • Parametrized queries

  • Parametrized output filename

Installation

To install all you need to do is run:

$ pip install --upgrade sqlexceller

Usage Help

usage: sqlexceller [-h] [-v] [--output OUTPUT] [--db_connection_info URL]
                   [--param PARAMS]
                   file [file ...]

sqlexceller tool
    The tool will execute SQL queries and generate an Excel file with the
    results.

positional arguments:
  file                  SQL Query file

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --output OUTPUT, -o OUTPUT
                        Output file
  --db_connection_info URL, -d URL
                        DB connection information as an URL in the form of
                          dialect[+driver]://username:password@host:port/database.
  --param PARAMS, -p PARAMS
                        Adds a parameter for the SQL queries. Parameter must
                        be specified as a key=value pair.  This argument can
                        be repeated as many times as necessary.

Available dialects and drivers are:
  - postgresql:
    - psycopg2
    - pg8000
  - mysql:
    - mysqldb
    - mysqlconnector
    - oursql
  - oracle:
    - cx_oracle
  - mssql:
    - pyodbc
    - pymssql
  - sqlite

There are some default parameters that will always be present:
  - NUM_QUERY
  - QUERY_NAME
  - DATE
  - DAY
  - MONTH
  - YEAR

Usage examples:
  - Execute a simple query on a SQLite DB.
      sqlexceller query.sql -d sqlite:///example.db

  - Execute multiple queries with 2 different parameters and a custom output
    file on a PostgreSQL DB:

      Contents of query1.sql:
        SELECT *
        FROM stocks
        where transaction = :transaction;

      Contents of query2.sql:
        SELECT *
        FROM stocks
        where transaction = :transaction and product = :product;

      sqlexceller query1.sql query2.sql -p transaction=BUY -p product=HAT \
          -o "report :trans (:MONTH-:DAY).xlsx" \
          -d postgresql://user:password@localhost/mydatabase

      Generated file will be something like: "report BUY (10-16).xlsx"

Reporting an issue

If you’ve found an issue with sqlexceller here’s how you can report the problem:

  • Preferred method is filing a bug on GitHub:

    1. Go to project’s issue tracker on GitHub

    2. Search for existing issues using the search field at the top of the page

    3. File a new issue with information on the problem

    4. Thanks for helping make sqlexceller better

  • If you don’t have a GitHub account and don’t wish to create one you can just drop me an email.

History

0.1.1 (2018-03-17)

  • Fix #1: Exception on empty result set from query

0.1.0 (2016-10-16)

  • First release on PyPI.

Metadata

Release files for sqlexceller 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlexceller 0.1.1
File Size Uploaded
sqlexceller-0.1.1.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlexceller 0.1.1
File Interpreter ABI Platform
sqlexceller-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 29.6 kB

Release files / sqlexceller-0.1.1.tar.gz

Download URL sqlexceller-0.1.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ae36d0311e59b2a27ce76dfa4a7745d63777208a40d13d4f70dbcd3147647365
BLAKE2b-256 checksum
How to use checksums
fb7bda7e8191dce5416bd7549c527bbfc6c343cd19e5aaada91939aad5860a25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / sqlexceller-0.1.1-py2.py3-none-any.whl

Download URL sqlexceller-0.1.1-py2.py3-none-any.whl
Size 8.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9aeaad58b242a362c5bf8394a8a5e7ac3f52f42f4809e02c46e968f08e5b3cbb
BLAKE2b-256 checksum
How to use checksums
481bf230dceea1550b6c60ed62f7957b6cb3274fc738ab2520c2ff71370230e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page