.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Printer::Filter::DB 3pm" .TH Data::Printer::Filter::DB 3pm 2024-04-27 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Data::Printer::Filter::DB \- pretty\-printing database objects (DBI, DBIx::Class, etc) .SH SYNOPSIS .IX Header "SYNOPSIS" In your \f(CW\*(C`.dataprinter\*(C'\fR file: .PP .Vb 1 \& filters = DB .Ve .PP You may also customize the look and feel with the following options (defaults shown): .PP .Vb 1 \& ### DBH settings: \& \& # expand database handle objects \& filter_db.connection_details = 1 \& \& \& ### DBIx::Class settings: \& \& # signal when a result column is dirty: \& filter_db.show_updated_label = 1 \& \& # signal when result rows contain extra columns: \& filter_db.show_extra_label = 1 \& \& # override class.expand for schema dump \& filter_db.schema.expand = 1 \& \& # expand DBH handle on schema dump (may touch DB) \& filter_db.schema.show_handle = 0 \& \& # show source details (connected tables) on schema dump \& # (may be set to \*(Aqnames\*(Aq, \*(Aqdetails\*(Aq or \*(Aqnone\*(Aq) \& filter_db.schema.loaded_sources = names \& \& # show source table name ResultSource objects \& filter_db.show_source_table = 1 \& \& # show source columns (\*(Aqnames\*(Aq, \*(Aqdetails\*(Aq or \*(Aqnone\*(Aq): \& filter_db.column_info = details \& \& # this plugin honors theme colors where applicable \& # and provides the following custom colors for you to use: \& colors.filter_db_connected = #a0d332 \& colors.filter_db_disconnected = #b3422d .Ve .PP That's it! .SH DESCRIPTION .IX Header "DESCRIPTION" This is a filter plugin for Data::Printer that displays (hopefully) more relevant information on database objects than a regular dump. .SS "Parsed Modules" .IX Subsection "Parsed Modules" \fIDBI\fR .IX Subsection "DBI" .PP If it's a database handle, for example, this filter may show you something like this: .PP .Vb 6 \& SQLite Database Handle (connected) { \& dbname: file.db \& Auto Commit: 1 \& Statement Handles: 2 (1 active) \& Last Statement: SELECT * FROM some_table \& } .Ve .PP You can show less information by setting this option on your \f(CW\*(C`.dataprinter\*(C'\fR: .PP .Vb 1 \& filter_db.connection_details = 0 .Ve .PP If you have a statement handler like this (for example): .PP .Vb 2 \& my $sth = $dbh\->prepare(\*(AqSELECT * FROM foo WHERE bar = ?\*(Aq); \& $sth\->execute(42); \& \& use DDP; p $sth; .Ve .PP This is what you'll get: .PP .Vb 1 \& SELECT * FROM foo WHERE bar = ? (42) .Ve .PP Note that if your driver does not support holding of parameter values, you'll get a \&\f(CW\*(C`bindings unavailable\*(C'\fR message instead of the bound values. .PP \fIDBIx::Class\fR .IX Subsection "DBIx::Class" .PP This filter is able to pretty-print many common DBIx::Class objects for inspection. Unless otherwrise noted, none of those calls will touch the database. .PP \&\fBDBIx::Class::Schema\fR objects are dumped by default like this: .PP .Vb 5 \& MyApp::Schema { \& connection: MySQL Database Handle (connected) \& replication lag: 4 \& loaded sources: ResultName1, ResultName2, ResultName3 \& } .Ve .PP If your \f(CW\*(C`.dataprinter\*(C'\fR settings have \f(CW\*(C`class.expand\*(C'\fR set to \f(CW0\fR, it will only show this: .PP .Vb 1 \& MyApp::Schema (MySQL \- connected) .Ve .PP You may override this with \f(CW\*(C`filter_db.schema.expand = 1\*(C'\fR (or 0). Other available options for the schema are (default values shown): .PP .Vb 4 \& # if set to 1, expands \*(Aqconnection\*(Aq into a complete DBH dump \& # NOTE: this may touch the database as it could try to reconnect \& # to fetch a healthy DBH: \& filter_db.schema.show_handle = 0 \& \& # set to \*(Aqdetails\*(Aq to view source details, or \*(Aqnone\*(Aq to skip it: \& filter_db.schema.loaded_sources = names .Ve .PP \&\fBDBIx::Class::ResultSource\fR objects will be expanded to show details of what that source represents on the database (as perceived by DBIx::Class), including column information and whether the table is virtual or not. .PP .Vb 9 \& User ResultSource { \& table: "user" \& columns: \& user_id integer not null auto_increment (primary), \& email varchar(100), \& bio text \& non\-primary uniques: \& (email) as \*(Aquser_email\*(Aq \& } .Ve .PP Ever got bit by DBIx::Class? .IX Subsection "Ever got bit by DBIx::Class?" .PP Let us know if we can help by creating an issue on Data::Printer's Github. Patches are welcome! .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Printer