dbi

Force mysql to throw error if no rows deleted (trying to delete non-existent row)

两盒软妹~` 提交于 2020-06-13 06:03:29
问题 I am using Perl DBI ( execute_array ), but I think that this is more of a mysql issue. I am trying to DELETE a few rows, and ran into the issue that the command completes successfully with no errors, but my rows are not being deleted (modified rows returns 0E0, i.e., "zero but true", i.e., "0 rows deleted"). When I tried via PHPMyAdmin , the rows deleted with no issue. After some debugging and long blank stares at my screen, I realized that one of the columns I was using in my DELETE

Force mysql to throw error if no rows deleted (trying to delete non-existent row)

旧街凉风 提交于 2020-06-13 06:01:39
问题 I am using Perl DBI ( execute_array ), but I think that this is more of a mysql issue. I am trying to DELETE a few rows, and ran into the issue that the command completes successfully with no errors, but my rows are not being deleted (modified rows returns 0E0, i.e., "zero but true", i.e., "0 rows deleted"). When I tried via PHPMyAdmin , the rows deleted with no issue. After some debugging and long blank stares at my screen, I realized that one of the columns I was using in my DELETE

Same dbGetQuery() call via odbc connection gives “Invalid Descriptor Index” error on some PCs but script runs fine on others

試著忘記壹切 提交于 2020-03-03 08:06:50
问题 I have an R script that works fine on my PC. I have sent it to a colleague to use as a source for Power BI, however it does not run (even from base R without Power BI) on their PC. The issue seems to be with DBI::GetQuery via an odbc connection, and the script is as such (I've changed the names of intellectual property and shortened the very long case_when statements): Database_connection <- dbConnect(drv = odbc::odbc(), Driver = "SQL Server", server = "addressofserver.database.windows.net",

Same dbGetQuery() call via odbc connection gives “Invalid Descriptor Index” error on some PCs but script runs fine on others

血红的双手。 提交于 2020-03-03 08:05:28
问题 I have an R script that works fine on my PC. I have sent it to a colleague to use as a source for Power BI, however it does not run (even from base R without Power BI) on their PC. The issue seems to be with DBI::GetQuery via an odbc connection, and the script is as such (I've changed the names of intellectual property and shortened the very long case_when statements): Database_connection <- dbConnect(drv = odbc::odbc(), Driver = "SQL Server", server = "addressofserver.database.windows.net",

Same dbGetQuery() call via odbc connection gives “Invalid Descriptor Index” error on some PCs but script runs fine on others

不问归期 提交于 2020-03-03 08:05:27
问题 I have an R script that works fine on my PC. I have sent it to a colleague to use as a source for Power BI, however it does not run (even from base R without Power BI) on their PC. The issue seems to be with DBI::GetQuery via an odbc connection, and the script is as such (I've changed the names of intellectual property and shortened the very long case_when statements): Database_connection <- dbConnect(drv = odbc::odbc(), Driver = "SQL Server", server = "addressofserver.database.windows.net",

Perl DBD::CSV - SQL Syntax - “AND” clause is not working properly

限于喜欢 提交于 2020-02-04 05:08:08
问题 I am running Perl 5.10 on Ubuntu 10.04 and using perl DBI module. I am trying to use the "AND" condition in "WHERE" clause in SQL Query under Perl DBI. I am using the DBD::CSV driver. Please consoider below test.csv: OS,RELEASE,VERSION Ubuntu,Warty,4 Ubuntu,Hoary,5 Ubuntu,Breezy,5 Fedora,Yarrow,1 Fedora,Tettnang,2 Fedora,Stentz,4 Here I want to retrieve the VERSION for Fedora Stentz. Here is my code: #!/usr/bin/perl -w use strict; use DBI; my $table = "test.csv"; my $dbh = DBI->connect ("dbi

DBI: disconnect - question

房东的猫 提交于 2020-02-03 04:59:31
问题 Would you call parts of the disconnect -code as line-noise or would you leave it as it is? use DBI; my $dbh = DBI->connect ... ... ... END { $dbh->disconnect or die $DBI::errstr if $dbh; } 回答1: Explicit disconnection from the database is not strictly necessary if you are exiting from your program after you have performed all the work. But it is a good idea, especially in programs in which you have performed multiple connections or will be carrying out multiple sequential connections. See

Perl DBI insert multiple rows using mysql native multiple insert ability

家住魔仙堡 提交于 2020-01-29 06:14:45
问题 Has anyone seen a DBI-type module for Perl which capitalizes, easily, on MySQL's multi-insert syntax insert into TBL (col1, col2, col3) values (1,2,3),(4,5,6),... ? I've not yet found an interface which allows me to do that. The only thing I HAVE found is looping through my array. This method seems a lot less optimal vs throwing everything into a single line and letting MySQL handle it. I've not found any documentation out there IE google which sheds light on this short of rolling my own code

Is MySQL more resistant to SQL injection attack than PostgreSQL (under Perl/DBI)?

删除回忆录丶 提交于 2020-01-21 05:17:07
问题 I am reviewing a Linux based perl web application that contains a login handler with the ubiquitous my $sth = $DB->prepare("SELECT password from passwords where userid='$userid'") or die; $sth->execute or die; ... where $userid is initialized from (unsafe, unfiltered) web user input. It is well known that the DBI documentation recommends that this code should be changed to use the placeholder "?" in place of '$userid' for security. This code was isolated on an off network box, as-is, for the

How can I use a query with placeholder inside quotes? (perl / postgresql)

青春壹個敷衍的年華 提交于 2020-01-20 08:05:10
问题 I'm trying to execute the following script: #!/usr/bin/perl -w use strict; use DBI; my $db = "Pg"; my $db_database = "whatever"; my $user = "whatever"; my $password = "whatever"; my $dbh = DBI->connect("dbi:$db:dbname=$db_database", $user, $password); my $query = $dbh->prepare (q{SELECT arrival_date - INTERVAL '? MINUTE' FROM emails LIMIT 1}) or die ("unable to prepare"); $query->execute(60) or die("unable to execute"); print $query->fetchrow_array, "\n"; (arrival_date has this format: