From 40494e4d153cf7cd5d3f9eb1f8da73692a27df84 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Wed, 15 Apr 2020 17:24:30 +0200 Subject: [PATCH] add perl dbh snippet --- snippets/cperl-mode/dbh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 snippets/cperl-mode/dbh diff --git a/snippets/cperl-mode/dbh b/snippets/cperl-mode/dbh new file mode 100644 index 00000000..94744e9e --- /dev/null +++ b/snippets/cperl-mode/dbh @@ -0,0 +1,33 @@ +# -*- mode: snippet -*- +# name: dbh +# key: dbh_ +# -- +my $dbh = DBI->connect( "dbi:ODBC:$params{database}", undef, undef, { + AutoCommit => 0, + odbc_ignore_named_placeholders => 1 + } ) or die "Can't connect to database: $DBI::errstr\n"; + +if ( $params{debug} ) { + if ( -e "DBI.log" ) { + unlink "DBI.log"; + } + if ( -e "SQL.log" ) { + unlink "SQL.log"; + } + if ( -e "dbi.prof" ) { + unlink "dbi.prof"; + } + + if ( $params{debug} >= 2 ) { + $dbh->trace(15, "DBI.log"); + $dbh->{Profile} = "6/DBI::ProfileDumper"; + } + else { + $dbh->trace(2, "DBI.log"); + $dbh->{Profile} = "2/DBI::ProfileDumper"; + } + + $dbh->{odbc_trace} = 1; + $dbh->{odbc_trace_file} = "SQL.log"; + print "running in debug mode: See DBI.log, SQL.log and dbi.prof in current directory\n"; +} -- 2.47.3