dbi

How do I install DBI module for Perl on Heroku machine

隐身守侯 提交于 2019-12-11 06:38:48
问题 So I have my Ruby-on-rails app that i successfully released to heroku. However to populate the database I have several perl scripts that basically sync up tables on local database with a remote database. On my development machine (on ec2) it works fine but I also have a lot of stuff i have installed on it over time. When I try to run my scripts I get the following error (latest perl is installed by the way) Can't locate DBI.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr

How do I insert values from a hash into a database using Perl's DBI module?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 06:13:17
问题 I need to insert values from a hash into a database. Following is the code template I have to insert values in table1 column key and value : use DBI; use strict; %hash; #assuming it already contains desired values my $dbh = DBI->connect( "dbi:Sybase:server=$Srv;database=$Db", "$user", "$passwd" ) or die sprintf 'could not connect to database %s', DBI->errstr; my $query= "Insert INTO table1(key, values) VALUES (?,?) "; my $sth = $dbh->prepare($query) or die "could not prepare statement\n",

is it possible execute a perl script with admin rights or as a specific user?

本秂侑毒 提交于 2019-12-11 05:29:30
问题 I'm writing a perl script in which I've to shutdown my mssql server ,do some operation and then I've to restart it.I know 1 way is to use netstat to stopt the service but I cann't use that. So I tried installing DBI and DBD::ODBC module. More info here :Shutdown MSSQL server from perl script DBI But when I trying to shutdown my server using this command $dbh->prepare("SHUTDOWN WITH NOWAIT "); It's not working for me : I got this response from the community SHUTDOWN permissions are assigned to

Perl dbi (select) fetches empy strings in array

我只是一个虾纸丫 提交于 2019-12-11 04:19:18
问题 I have a perl script that connect to a postgres db and fetches a couple select statements that it runs on it. This output have the purpose to print in word afterword. While i was building my project i didn't notice something that happens with the fetching part ,it was after i print it in word that i noticed something strange. I execute a select statement and fetches this in an arrayref , but when i print this arrayreferentie I don't got only values in my array but also empty strings and de

Unable to locate DBI.pm module in Perl

佐手、 提交于 2019-12-11 03:13:21
问题 I am using CentOS, and I have installed Perl 5.20 and Perl 5.10 was present by default. I am using the Perl 5.20 version to execute the Perl code I am trying to use the DBI module and get this error [root@localhost ~]#perl -e 'use DBI;' Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /usr/local/lib/perl5/site_perl/5.20.1/i686-linux /usr/local/lib/perl5/site_perl/5.20.1 /usr/local/lib/perl5/5.20.1/i686-linux /usr/local/lib/perl5/5.20.1 .) at -e line 1.

How can I have DBIC persistent database connection in mod_perl?

假装没事ソ 提交于 2019-12-11 01:27:51
问题 I am using mod_perl for my web application. Currently, I plan to use a mysql database across the network. In every CGI request to display_customer_transaction.cgi, my script will Open up database connection across network Perform query on the database using SQL statement Analysis the data retrieved from database Print out the data in HTML format Close the database connection After some profiling, I realize step (1) is the bottleneck. Hence, I wish to avoid opening and closing a database

How to store the runtime mssql error in a variable and continue to run in perl?

让人想犯罪 __ 提交于 2019-12-11 00:37:13
问题 I'm trying to store the runtime mssql error in variable and continue with all other data. my $sth = $dbh->prepare("exec TEST_ABC_DB.dbo.testprocedure"); $sth->execute() ; my $db_error =$DBI::errstr; #It didn't work also I tried err and state print "\nDB error $db_error\n"; while (@row = $sth->fetchrow_array( ) ) { print "Row: @row\n"; } I used the eval block but it is also not working. My procedure as follows,(sample) CREATE procedure testprocedure as select 'one' select 'three' select 10/0

How can I insert array data into MySQL in Perl?

爷,独闯天下 提交于 2019-12-11 00:36:47
问题 I parse a text file with the script below. How to insert the array data to MySQL table? I already learned Perl MySQL DBI connect method. And I can connect to local MySQL DB successfully. I can create the table with MySQL command line. #!C:\Perl\bin\perl.exe use strict; use warnings; while ( <DATA> ) { my @rocks = split(/\s+/, $_); foreach my $rock (@rocks) { $rock = "\t$rock "; # put a tab in front of each element of @rocks $rock .= "\n"; # put a newline on the end of each print $rock ; } } _

Ruby DBI select_all vs execute-fetch/each-finish

与世无争的帅哥 提交于 2019-12-10 21:49:19
问题 Here is my sample code for using DBI: dbh = DBI.connect("DBI:Mysql:host=#{server};database=mysql", user, pass) rows = dbh.select_all("SHOW TABLES") Here the rows is printed as below: [["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"], ["user"]] This is printing the last table in mysql database, but the total number of records is proper. If I do this using execute-fetch/each-finish

How can I make DBI log all queries including params?

自古美人都是妖i 提交于 2019-12-10 20:56:51
问题 I am trying to figure out what a legacy app does to our mysql databases (plural) as I need to refactor/replace a part of it completely without caring how it does it. I'm just interested in the result. Currently I am working with DBI::Profile and DBI::ProfileDumper by adding $ENV{DBI_PROFILE} = "!Statement/DBI::ProfileDumper"; . That shows me a bunch of queries when running dbiprof dbi.prof on the commandline, but it seems a little odd. Might be I am reading the report wrong. #####[ 3 ]#######