App-MysqlUtils
view release on metacpan or search on metacpan
(No description)
* username => *str*
Will try to get default from "~/.my.cnf".
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
mysql_fill_csv_columns_from_query
Usage:
mysql_fill_csv_columns_from_query(%args) -> [$status_code, $reason, $payload, \%result_meta]
Fill CSV columns with data from a query.
This utility is handy if you have a partially filled table (in CSV
format, which you can convert from spreadsheet or Google Sheet or
whatever), where you have some unique key already specified in the table
(e.g. customer_id) and you want to fill up other columns (e.g.
customer_name, customer_email, last_order_date) from a query:
% mysql-fill-csv-columns-from-query DBNAME TABLE.csv 'SELECT c.NAME customer_name, c.email customer_email, (SELECT date FROM tblorders WHERE client_id=$customer_id ORDER BY date DESC LIMIT 1) last_order_time FROM tblclients WHERE id=$customer_id...
The $NAME in the query will be replaced by actual CSV column value.
SELECT fields must correspond to the CSV column names. For each row, a
new query will be executed and the first result row is used.
This function is not exported.
This function supports dry-run operation.
Arguments ('*' denotes required arguments):
* count => *bool*
Instead of returning the CSV rows, just return the count of rows
that get filled.
* database* => *str*
(No description)
* escape_char => *str*
Specify character to escape value in field in input CSV, will be
passed to Text::CSV_XS.
Defaults to "\\" (backslash). Overrides "--tsv" option.
* filename* => *filename*
Input CSV file.
* header => *bool* (default: 1)
Whether input CSV has a header row.
By default ("--header"), the first row of the CSV will be assumed to
contain field names (and the second row contains the first data
row). When you declare that CSV does not have header row
("--no-header"), the first row of the CSV is assumed to contain the
first data row. Fields will be named "field1", "field2", and so on.
* host => *str* (default: "localhost")
(No description)
* password => *str*
Will try to get default from "~/.my.cnf".
* port => *int* (default: 3306)
(No description)
* query* => *str*
(No description)
* quote_char => *str*
Specify field quote character in input CSV, will be passed to
Text::CSV_XS.
Defaults to """ (double quote). Overrides "--tsv" option.
* sep_char => *str*
Specify field separator character in input CSV, will be passed to
Text::CSV_XS.
Defaults to "," (comma). Overrides "--tsv" option.
* tsv => *bool*
Inform that input file is in TSV (tab-separated) format instead of
CSV.
Overriden by "--sep-char", "--quote-char", "--escape-char" options.
If one of those options is specified, then "--tsv" will be ignored.
* username => *str*
Will try to get default from "~/.my.cnf".
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
mysql_find_identical_rows
Usage:
mysql_find_identical_rows(%args) -> [$status_code, $reason, $payload, \%result_meta]
List rows on one table that are identical on another table.
This function is not exported.
Arguments ('*' denotes required arguments):
* database* => *str*
(No description)
* exclude_columns => *array[str]*
What column(s) to exclude from comparison.
* host => *str* (default: "localhost")
(No description)
* password => *str*
Will try to get default from "~/.my.cnf".
* port => *int* (default: 3306)
(No description)
* return_column* => *str*
What column to return.
( run in 2.183 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )