1DBI::Dumper(3) User Contributed Perl Documentation DBI::Dumper(3)
2
3
4
6 DBI::Dumper - Dump data from a DBI datasource to file.
7
9 << in test.ctl >>
10 OPTIONS (export=100,rows=100)
11 EXPORT DATA REPLACE INTO FILE 'test.dat'
12 FIELDS TERMINATED BY TAB
13 ENCLOSED BY '"' AND '"'
14 ESCAPED BY '\'
15 WITH HEADER FROM
16 SELECT * FROM MY_TABLE
17
18 my $dumper = DBI::Dumper->new(
19 -dbh => $dbh,
20 -control => 'test.ctl',
21 -output => 'test.dat',
22 );
23
24 $dumper->prepare;
25 $dumper->execute;
26
27 # have DBI::Dumper login to database
28 my $dumper = DBI::Dumper->new(
29 -userid => 'user/pass@sid',
30 ...
31 );
32
33 # send a statement handle instead of database handle
34 my $sth = DBI->connect()->prepare("SELECT * FROM MY TABLE");
35 $dumper->execute($sth);
36
38 Dumps data from a select statement into an output file. dbidumper tries
39 to mirror the functionality and behavior of sql*loader. The control
40 file syntax is similar, and DBI::Dumper utilizes a subset of the
41 sql*loader options.
42
43 Configuration options can be set either in the control file, passed to
44 the new() method, or by calling the option's accessor.
45
46 Options
47
48 userid=username/password@sid
49 Login information for database connection.
50
51 If the sid includes a colon, the full string will be used as the
52 DBI dsn. For example:
53
54 userid=username/password@mysql:database
55
56 Will connect to mysql's 'database' database as username.
57
58 Otherwise, DBI::Dumper assumes a dbi:Oracle connection and prefixes
59 the dsn with dbi:Oracle:. If no dsn is passed, DBI::Dumper first
60 looks in $ENV{DBI_DSN} then $ENV{ORACLE_SID}.
61
62 control=filename
63 Input control filename. Defaults to standard input. See "CONTROL
64 FILE" for layout and description.
65
66 output=filename
67 Output filename for data. Defaults to standard output. If rows is
68 given, can contain template consisting of three or more Xs. The Xs
69 will be replaced with the file sequence number. If the template
70 does not contain three or more Xs, the sequence number will be
71 appended to the filename with a dot. Examples:
72
73 rows=n
74 Number of rows per output file. Defaults to all rows in one output
75 file.
76
77 export=n
78 Total number of rows to export. Use to limit output or restart
79 dump.
80
81 skip=n
82 Number of rows to skip from beginning. File sequence number will be
83 preserved, so if rows=n is set, this can be used to restart a job.
84
85 bindsize=n
86 Block size to write file. Defaults to write each record as returned
87 from database. If set, dbidumper will collect rows into a buffer at
88 most n bytes large before writing to file.
89
90 silent=true
91 Suppress normal logging information. dbidumper will only report
92 errors.
93
94 Exporting to Multiple Files
95
96 rows=1000 output=outputXXXXX.dat
97 Data will be written to output00001.dat, output00002.dat, etc.
98
99 rows=1000 output=output.dat
100 Data will be written to output.dat.0001, output.dat.0002, etc.
101
102 output=outputXXXXX.dat
103 Data will be written to outputXXXXX.dat
104
106 This program depends on the following perl modules, available from a
107 CPAN mirror near you:
108
109 Parse::RecDescent - Recursive parser
110 DBI - Standard database interface
111
113 The control file used for dbidumper is very similar to sql*loader's.
114 The full specification is:
115
116 [ OPTIONS ([option], ...) ]
117 EXPORT DATA [ REPLACE ⎪ APPEND ] [ INTO FILE 'filename' ]
118 [ FIELDS
119 [ TERMINATED [BY] {TAB ⎪ 'string' ⎪ X'hexstring'} ] ⎪
120 [ ENCLOSED [BY] {'string' ⎪ X'hexstring'}
121 [AND] ['string' ⎪ X'hexstring'] ]
122 [ ESCAPED [BY] {'string' ⎪ X'hexstring'} ]
123 ]
124 [ WITH HEADER ]
125 FROM
126 select_statement
127
129 Written by Warren Smith (warren.smith@acxiom.com)
130
132 None yet.
133
134
135
136perl v5.8.8 2006-03-09 DBI::Dumper(3)