csv2db.py - upload table to database

Tags

Python

Purpose

create a table from a csv separated file and load data into it.

This module supports backends for postgres and sqlite3. Column types are auto-detected.

Read a table from stdin and create an sqlite3 database. By default, the database will reside in a file called csvdb and in a table csv.

Todo

Use file import where appropriate to speed up loading. Currently, this is not always the case.

Usage

Example:

python csv2db.py -b sqlite < stdin

Type:

python csv2db.py --help

for command line help.

Command line options

usage: csv2db [-h] [--version] [--csv-dialect DIALECT] [-m MAP] [-t TABLENAME]
              [-H HEADER_NAMES] [--replace-header] [-l]
              [--chunk-size CHUNK_SIZE] [--ignore-column IGNORE_COLUMNS]
              [--rename-column RENAME_COLUMNS] [--first-column FIRST_COLUMN]
              [-e] [-i INDICES] [-a] [--retry] [--append] [--utf8]
              [--timeit TIMEIT_FILE] [--timeit-name TIMEIT_NAME]
              [--timeit-header] [--random-seed RANDOM_SEED] [-v LOGLEVEL]
              [--log-config-filename LOG_CONFIG_FILENAME]
              [--tracing {function}] [-? ?] [-I STDIN] [-L STDLOG] [-E STDERR]
              [-S STDOUT] [--database-url DATABASE_URL]
              [--database-schema DATABASE_SCHEMA]
csv2db: error: argument -?: expected one argument