Skip to main content

No project description provided

Project description


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


# 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.


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
-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



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

Project details

Download files

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

Files for sql-extract, version 0.3.3
Filename, size File type Python version Upload date Hashes
Filename, size sql_extract-0.3.3-py3.7.egg (11.5 kB) File type Egg Python version 3.7 Upload date Hashes View
Filename, size sql_extract-0.3.3-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size sql_extract-0.3.3.tar.gz (6.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page