Bugzilla – Attachment 13923 Details for
Bug 9045
Adding some parameters to export_borrowers.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 9045 : Adding --where parameter to filter what kind of borrowers to export and --separator to choose a specific caracter for patron export
Bug-9045--Adding---where-parameter-to-filter-what-.patch (text/plain), 2.73 KB, created by
Kyle M Hall (khall)
on 2012-12-07 14:13:15 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 9045 : Adding --where parameter to filter what kind of borrowers to export and --separator to choose a specific caracter for patron export
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-12-07 14:13:15 UTC
Size:
2.73 KB
patch
obsolete
>From 982622ad6f9a26cbd0b35fddda8ee9a19aae1b1a Mon Sep 17 00:00:00 2001 >From: Sophie Meynieux <sophie.meynieux@biblibre.com> >Date: Fri, 9 Nov 2012 18:02:33 +0100 >Subject: [PATCH] Bug 9045 : Adding --where parameter to filter what kind of borrowers to export and --separator to choose a specific caracter for patron export > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Tested, works as advertised. Note, to use tab character as a separater, do this: -s $'\t' >--- > misc/export_borrowers.pl | 18 +++++++++++++++--- > 1 files changed, 15 insertions(+), 3 deletions(-) > >diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl >index c4b3e40..e4fa7b0 100755 >--- a/misc/export_borrowers.pl >+++ b/misc/export_borrowers.pl >@@ -37,14 +37,20 @@ $basename > It prints to standard output. Use redirection to save CSV in a file. > > Usage: >-$0 [--field=FIELD [--field=FIELD [...]]] [--show-header] >+$0 [--field=FIELD [--field=FIELD [...]]] [--separator=CHAR] [--show-header] [--where=CONDITION] > $0 -h > > -f, --field=FIELD Field to export. It is repeatable and has to match > keys returned by the GetMemberDetails function. > If no field is specified, then all fields will be > exported. >+ -s, --separator=CHAR This character will be used to separate fields. >+ Some characters like | or ; will need to be escaped >+ in the parameter setting, like -s=\\| or -s=\\; >+ If no separator is specifield, a comma will be used. > -H, --show-header Print field names on first row >+ -w, --where=CONDITION Condition to filter borrowers to export >+ (SQL where clause) > -h, --help Show this help > > USAGE >@@ -52,12 +58,16 @@ USAGE > > # Getting parameters > my @fields; >+my $separator; > my $show_header; >+my $where; > my $help; > > GetOptions( > 'field|f=s' => \@fields, >+ 'separator|s=s' => \$separator, > 'show-header|H' => \$show_header, >+ 'where|w=s' => \$where, > 'help|h' => \$help > ) or print_usage, exit 1; > >@@ -68,11 +78,13 @@ if ($help) { > > # Getting borrowers > my $dbh = C4::Context->dbh; >-my $query = "SELECT borrowernumber FROM borrowers ORDER BY borrowernumber"; >+my $query = "SELECT borrowernumber FROM borrowers"; >+$query .= " WHERE $where" if ($where); >+$query .= " ORDER BY borrowernumber"; > my $sth = $dbh->prepare($query); > $sth->execute; > >-my $csv = Text::CSV->new( { binary => 1 } ); >+my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } ); > > # If the user did not specify any field to export, we assume he wants them all > # We retrieve the first borrower informations to get field names >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9045
:
13362
|
13363
|
13923
|
16249
|
16440
|
16578
|
16579