Skip to content

CLI#11

Open
mjumbewu wants to merge 25 commits intomasterfrom
cli
Open

CLI#11
mjumbewu wants to merge 25 commits intomasterfrom
cli

Conversation

@mjumbewu
Copy link
Contributor

Add a command line interface for common tasks

$ datum
# Usage: datum [OPTIONS] COMMAND [ARGS]...
# 
# Options:
#   --help  Show this message and exit.
# 
# Commands:
#   execute
#   load
#   truncate

$ datum truncate --help
# Usage: datum truncate [OPTIONS] TABLE
# 
# Options:
#   -d, --connection TEXT  The database connection string  [required]
#   --help                 Show this message and exit.

$ datum load --help
# Usage: datum load [OPTIONS] CSVFILE TABLE
# 
# Options:
#   -d, --connection TEXT  The database connection string  [required]
#   --help                 Show this message and exit.

$ datum execute --help
# Usage: datum execute [OPTIONS] SQL
# 
# Options:
#   -d, --connection TEXT  The database connection string  [required]
#   --help                 Show this message and exit.

For Oracle STGeom DB connections, the connection strings are in the format 'oracle-stgeom://<username>:<password>@<dsn>', where a DSN is of the following form (except on one line):

(DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = ...)(PORT = ...))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = ...)
   )
 )

Unquoted, case-insensitive names would be preferable, but we were getting a number
of "ORA-00942: table or view does not exist" and "ORA-00904: invalid identifier"
errors for tables or fields that had been created with quoted names initially.
Protects against reserved words like VIEW or END as variables
This will allow us to create an additional function for an upsert statement
@timwis
Copy link
Contributor

timwis commented Oct 1, 2016

Woo! Was just thinking about this yesterday. Awesome!

The previous version would not always terminate because it did not know
when the iterable was depleted 😞. The new version is based
on `islice` and `chain` from itertools, and is sourced from from
http://stackoverflow.com/a/24527424.
Recursively include datum's sub-packages
Import the `os` module for use in the `get_packages` function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants