Given a query such as
SELECT order_id,product_name,qty FROM orders
which returns three columns of data, the results can be placed into the file /tmo/orders.txt using the query:
SELECT order_id,product_name,qty FROM orders
| #!/bin/bash | |
| app_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| app_name="$(basename "${BASH_SOURCE[0]}")" | |
| pid_file="${app_path}/run.pid" | |
| VERSION="${app_name} ver. 0.9.0" | |
| function help () { | |
| cat <<EOF | |
| usage: ${app_name} [-h] [-v] |
| graphite_index = json.loads(open('index.json').read()) | |
| result = json.dumps(instances, sort_keys=True, indent=4, encoding='utf-8') |
| # Recipe 6.18. Automatically Initializing Instance Variables from _ _init_ _ Arguments | |
| # Solution | |
| # You can "factor out" the attribute-assignment task to an auxiliary function: | |
| def set_attributes_from_dict(d): | |
| self = d.pop('self') | |
| for n, v in d.iteritems(): | |
| setattr(self, n, v) | |
| # Now, the typical boilerplate code for an _ _init_ _ method such as: |
| function httpdate2unixtimestamp(date, array, time_string, timestamp) { | |
| # input: [02/Dec/2011:04:02:42 -0500] | |
| # output: 1322816562 | |
| # date is argument | |
| # array, time_string, timestamp is local variable | |
| split(date, array, "[]/: []") | |
| if (array[3]=="Jan") month="01" | |
| else if (array[3]=="Feb") month="02" | |
| else if (array[3]=="Mar") month="03" | |
| else if (array[3]=="Apr") month="04" |
| # Associative Arrays | |
| declare -A characters | |
| AA="abcdabcaba" | |
| for ((x=0; x<${#AA}; x++)) | |
| do | |
| tmp=${AA:$x:1} | |
| ((characters[$tmp]++)) | |
| done |