Skip to main content

sql-extract

Exports the results of Oracle sql code contained in a .sql file out to a csv file.

Usage

# with input file
sql-extract in_sql_file.sql -o output_file.csv

# with quick text
sql-extract -t "select 1 from dual" -o output_file.csv

# with named bind parameters
sql-extract -t "select * from phonebook where first_name=:fn and last_name=:ln" -b fn=Dennis ln=Nedry -o output_file.csv

# additional help
sql-extract -h

Note: if you do not provide an output file with -o, the tool will simply output the data to a .csv file with the same base file name as the input file (test.sql -> test.csv). If -t is used, and no output file path is provided, the results will be sent to stdout.

Parameters

Name Description Type Required
filename input .sql file name string yes
-o, --outfile output .csv file name string no
-d, --delimiter .csv delimiter string no
-c, --quotechar .csv quote character string no
-i, --heading .csv include column headings Y/N string no
-l, --login Oracle login string string no
-p, --password Oracle password string no
-t, --text SQL query text (instead of file) string no
-b, --bind-variables Any named bind parameters in the .sql file, must follow param=value convention list no
positional_variables any positional variables in the .sql file list no

Unit Testing

./unittests.py

Configuration

Store your Oracle login and password in full_login and db_password environment variables, respectively. Otherwise, you must use --login and --password to pass in your credential(s). You can alternatively store your login as an environment variable but not your password (or vice versa).

Additional examples

# this will print out comma-sep data, rather than write it to disk
sql-extract -t "select * from general.people where first_name=:p_name;" -b p_name=Dennis

# this will write to disk
sql-extract -t "select * from general.people where first_name=:p_name;" -b p_name=Dennis -o /some/path/to/file.csv

# this will write to disk at given -o location
sql-extract /some/input/file.sql -b p_name=Dennis -o /some/path/to/file.csv

# this will write to disk at /some/input/file.csv
sql-extract /some/input/file.sql -b p_name=Dennis

Release files for sql-extract 0.3.5

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

Source distribution (sdist)

Source distribution for sql-extract 0.3.5
File Size Uploaded
sql_extract-0.3.5.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sql-extract 0.3.5
File Interpreter ABI Platform
sql_extract-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / sql_extract-0.3.5.tar.gz

Download URL sql_extract-0.3.5.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9061f8d064594bd24ff08664eccda0d8b00ba0712d5c87bab5c9fd47c50b1cdc
BLAKE2b-256 checksum
How to use checksums
e8c08c59ebc3e34e39f548f28206f4ff42fa7972cea56c4fb4e6f36410981141
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.1

Release files / sql_extract-0.3.5-py3-none-any.whl

Download URL sql_extract-0.3.5-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bf7b2bef92be74e5249167b86b56f9aaa57c8b032130f78fd6dd984fe8b7750
BLAKE2b-256 checksum
How to use checksums
6e950a5a75dd135c1d2bb28d5ce539c4bfd26e5d66c6d58ba9cb62d8b0676e9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 release files

0.3.4

2 release files

0.3.3

3 release files

0.3.2

3 release files

0.3.1

2 release files

0.3

1 release file

0.2

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

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