Sponsored Content
Top Forums Shell Programming and Scripting How to use Perl's DBI connect when no mysql passwd is set? Post 302325254 by cbkihong on Sunday 14th of June 2009 04:42:18 AM
Old 06-14-2009
I can't see where $connect is assigned a value. Try $dbh->prepare.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies

2. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

3. Shell Programming and Scripting

Installing Perl DBI and DBD

Hi, i have some queries on installing the Perl DBI and the DBD Oracle. I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI Perl Makefile.PL make make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies

4. Shell Programming and Scripting

connect to MySQL from Perl using DBI

Hi, I want to connect perl with the mysql to select and so on but the connection don't work code #!/usr/bin/perl BEGIN { # PERL MODULES WE WILL BE USING use DBI; $dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;} #... (1 Reply)
Discussion started by: eng_shimaa
1 Replies

5. Solaris

DBI with MySQL client library compile on Solaris

how dow you complie perl module DBI with mysql from /usr/local/mysql/bin keeps going to mysql client for /usr/sfw/bin is it the LD_PATH ???...:confused: error is # perl login.cgi DBI connect('customers;mysql_socket=/tmp/mysql.sock:localhost','root',...) failed: Client does not... (1 Reply)
Discussion started by: photon
1 Replies

6. UNIX for Advanced & Expert Users

Perl's DBI Module on OS X - uninstallable?

i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error: Mon Apr 19 09:43:29 EDT 2010 /Library/Perl/DBD-mysql-4.011 -> peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies

7. Shell Programming and Scripting

perl: help with DBI

Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough) $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

8. Shell Programming and Scripting

Perl DBI error

Hi All, I installed DBI module in a non INC location and using it in my script via "use lib". But it throw the below error at the "use DBI" step. Please help Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies

9. Shell Programming and Scripting

Perl: connect to network devices, run set of commands

I am trying to write a script for my own use that will allow me to connect to network devices, then run a set of commands. I start with a list of ips in a text file. Each ip is on its own line. I start with a second file of commands. Each command on one line. for illustration .. the cmd.txt... (2 Replies)
Discussion started by: popeye
2 Replies

10. Shell Programming and Scripting

Perl Oracle DBI through Apache problem

Experts, I've been struggling with making a Perl Oracle DBI script to work through my Apache webserver. Mysql DBI scripts work fine, but I'm having issue's with Oracle. The oracle script works on command line, but I'm getting an "Internal Server Error" with apache Sourcing the oracle... (0 Replies)
Discussion started by: timj123
0 Replies
CGI::Application::Plugin::DBH(3pm)			User Contributed Perl Documentation			CGI::Application::Plugin::DBH(3pm)

NAME
CGI::Application::Plugin::DBH - Easy DBI access from CGI::Application SYNOPSIS
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/); sub cgiapp_init { my $self = shift; # use the same args as DBI->connect(); $self->dbh_config($data_source, $username, $auth, \%attr); # or to use more than one dbh $self->dbh_config('my_handle', [ $data_source, $user, $auth, \%attr ]); $self->dbh_config('my_other_handle', [ $data_source, $user, $auth, \%attr ]); } sub my_run_mode { my $self = shift; my $date = $self->dbh->selectrow_array("SELECT CURRENT_DATE"); # again with a named handle $date = $self->dbh('my_handle')->selectrow_array("SELECT CURRENT_DATE"); # OR ... my $dbh = $self->dbh; # again with a named handle $dbh = $self->dbh('my_other_handle'); my $date = $dbh->selectrow_array("SELECT CURRENT_DATE"); } DESCRIPTION
CGI::Application::Plugin::DBH adds easy access to a DBI database handle to your CGI::Application modules. Lazy loading is used to prevent a database connection from being made if the "dbh" method is not called during the request. In other words, the database connection is not created until it is actually needed. METHODS
dbh() my $date = $self->dbh->selectrow_array("SELECT CURRENT_DATE"); # again with a named handle $date = $self->dbh('my_handle')->selectrow_array("SELECT CURRENT_DATE"); # OR ... my $dbh = $self->dbh; # again with a named handle $dbh = $self->dbh('my_other_handle'); my $date = $dbh->selectrow_array("SELECT CURRENT_DATE"); This method will return the current DBI database handle. The database handle is created on the first call to this method, and any subsequent calls will return the same handle. dbh_config() sub cgiapp_init { my $self = shift; # use the same args as DBI->connect(); $self->dbh_config($data_source, $username, $auth, \%attr); # or to use more than one dbh $self->dbh_config('my_handle', [ $data_source, $user, $auth, \%attr ]); $self->dbh_config('my_other_handle', [ $data_source, $user, $auth, \%attr ]); # ...or use some existing handle you have $self->dbh_config($DBH); $self->dbh_config('my_handle', $DBH); # this works too # Use a callback to create your owh handle that is still lazy loaded $self->dbh_config(sub { DBI->connect_cached(); }); } Used to provide your DBI connection parameters. You can either pass in an existing DBI database handle, or provide the usual parameters used for DBI->connect(). The recommended place to call "dbh_config" is in the "cgiapp_init" stage of CGI::Application. If this method is called after the database handle has already been accessed, then it will die with an error message. Automatic configuration using CGI::App instance parameters An alternative to explicitly calling "dbh_config" in your application is to rely on the presence of specific instance parameters that allow the plugin to configure itself. If you set the CGI::App parameter "::Plugin::DBH::dbh_config" to an array reference the contents of that array will be used as parameters to "dbh_config" (if it has not been explicitly called before). The code in the synopsis can be rewritten as use CGI::Application::Plugin::DBH (qw/dbh/); # no longer a need to import dbh_config sub cgiapp_init { # you do not need to do anything here } sub my_run_mode { # this part stays unchanged .... } and in the instance script ( or instance configuration file, if you have) $app->param('::Plugin::DBH::dbh_config' => [ $data_source, $username, $auth, \%attr ] ); If you want to configure more than one handle, set up a hash with the handle names as keys: $app->param('::Plugin::DBH::dbh_config' => { my_handle => [ $data_source, $username, $auth, \%attr ] , my_other_handle => [ $data_source, $username, $auth, \%attr ] } ); Automatic configuration with DBI environment variables If you do not set any parameters, and do not call "dbh_config", this plugin checks to see if you set the DBI environment variable "DBI_DSN". If present, this DSN will be used for the default handle. Note that the DBI documentation does not encourage using this method (especially in the context of web applications), that you will most likely have to also set "DBI_USER" and "DBI_PASS", and that this can only be used for the default handle. dbh_default_name() sub my_runmode { my $self = shift; my $old_handle_name = $self->dbh_default_name('my_handle'); $self->some_legacy_code(); # some_legacy_code() will get "my_handle" # when it calls $self->dbh() without parameters $self->dbh_default_name($old_handle_name); # Return to normal. } Can be used to alter the name of the handle that is returned by dbh() when called with no parameters. It can even be used to alter the name used for the unamed handle if called before dbh_config(). Using this method is completely optional. If you don't have a use for it don't use it. Internally the handle name "__cgi_application_plugin_dbh" is used to keep track of the unnamed handle unless it is changed by dbh_default_name() before a call to dbh_config() without a name parameter. SEE ALSO
Ima::DBI is similar, but has much more complexity and features. CGI::Application, DBI, CGI::Application::Plugin::ValidateRM, perl(1) AUTHOR
Mark Stosberg <mark@summersault.com> Multi Handle Support added by: Tony Fraser <tony@sybaspace.com> Autoconfig Support added by: Thilo Planz <thilo@cpan.org> LICENSE
Copyright (C) 2004 Mark Stosberg <mark@summersault.com> This library is free software. You can modify and or distribute it under the same terms as Perl itself. perl v5.12.3 2011-06-26 CGI::Application::Plugin::DBH(3pm)
All times are GMT -4. The time now is 10:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy