1Data::Printer::Filter::UDsBe(r3)Contributed Perl DocumenDtaattai:o:nPrinter::Filter::DB(3)
2
3
4
6 Data::Printer::Filter::DB - pretty printing database objects
7
9 In your program:
10
11 use Data::Printer filters => {
12 -external => [ 'DB' ],
13 };
14
15 or, in your ".dataprinter" file:
16
17 {
18 filters => {
19 -external => [ 'DB' ],
20 },
21 };
22
24 This is a filter plugin for Data::Printer. It filters through DBI's
25 handlers (dbh) and statement (sth) objects displaying relevant
26 information for the user. It also filters any object which inherits
27 from DBIx::Class::Schema, DBIx::Class::ResultSet or
28 DBIx::Class::ResultSetColumn.
29
30 DBI Sample Output
31 DBI is an extremely powerful and complete database interface. But it
32 does a lot of magic under the hood, making their objects somewhat
33 harder to debug. This filter aims to fix that :)
34
35 For instance, say you want to debug something like this:
36
37 use DBI;
38 my $dbh = DBI->connect('dbi:DBM(RaiseError=1):', undef, undef );
39
40 A regular Data::Dumper output gives you absolutely nothing:
41
42 $VAR1 = bless( {}, 'DBI::db' );
43
44 Data::Printer makes it better, but only to debug the class itself, not
45 helpful at all to see its contents and debug your own code:
46
47 DBI::db {
48 Parents DBI::common
49 Linear @ISA DBI::db, DBI::common
50 public methods (48) : begin_work, clone, column_info, commit, connected, data_sources, disconnect, do, foreign_key_info, get_info, last_insert_id, ping, prepare, prepare_cached, preparse, primary_key, primary_key_info, quote, quote_identifier, rollback, rows, selectall_arrayref, selectall_hashref, selectcol_arrayref, selectrow_array, selectrow_arrayref, selectrow_hashref, sqlite_backup_from_file, sqlite_backup_to_file, sqlite_busy_timeout, sqlite_collation_needed, sqlite_commit_hook, sqlite_create_aggregate, sqlite_create_collation, sqlite_create_function, sqlite_enable_load_extension, sqlite_last_insert_rowid, sqlite_progress_handler, sqlite_register_fts3_perl_tokenizer, sqlite_rollback_hook, sqlite_set_authorizer, sqlite_update_hook, statistics_info, table_info, tables, take_imp_data, type_info, type_info_all
51 private methods (0)
52 internals: {
53 }
54 }
55
56 Fear no more! If you use this filter, here's what you'll see:
57
58 SQLite Database Handle (connected) {
59 dbname: file.db
60 Auto Commit: 1
61 Statement Handles: 0
62 Last Statement: -
63 }
64
65 Much better, huh? :)
66
67 Statement handlers are even better. Imagine you continued your code
68 with something like:
69
70 my $sth = $dbh->prepare('SELECT * FROM foo WHERE bar = ?');
71 $sth->execute(42);
72
73 With this filter, instead of an empty dump or full method information,
74 you'll get exactly what you came for:
75
76 SELECT * FROM foo WHERE bar = ? (42)
77
78 Note that if your driver does not support holding of parameter values,
79 you'll get a "bindings unavailable" message instead of the bound
80 values.
81
83 Data::Printer, Data::Printer::Filter
84
85
86
87perl v5.32.0 2020-07-28 Data::Printer::Filter::DB(3)