Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

DBI::db error I am confused!

by traincity (Sexton)
on Jan 03, 2021 at 19:39 UTC ( [id://11126230]=perlquestion: print w/replies, xml ) Need Help??

traincity has asked for the wisdom of the Perl Monks concerning the following question:

Hi... I am trying to go localhost on Windows using strawberry. Strawberry Perl (64-bit) 5.30.0.1-64bit Apache 2.4.

Seems to work ok with workbench until I got to a perl script that writes to the database. Initially I get this error:

'Sun Jan 03 13:58:34.152049 2021 cgi:error pid 4756:tid 1100 client ::1:56303 AH01215: Can't locate object method "finish" via package "DBI::db" at C:/Apache24/htdocs/choo/cgi-bin/ua/newitem.pl line 65.\r: C:/Apache24/htdocs/choo/cgi-bin/ua/newitem.pl, referer: http://localhost/choo/cgi-bin/ua/newitem.pl'

I know dbi is in strawberry/perl/vendor/lib So I'm not sure if it is a configuration problem with apache or something else. This program works well online. I am trying to get it to work localhost for testing purposes. Thanks much for any help.

Replies are listed 'Best First'.
Re: DBI::db error I am confused!
by 1nickt (Canon) on Jan 03, 2021 at 19:50 UTC

    Hi, please show the relevant code. See I know what I mean. Why don't you?.

    PS : per the DBI docs, calling finish() explicitly is rarely needed... and finish() is a statement handle method, not a db handle method ... fwiw


    The way forward always starts with a minimal test.
Re: DBI::db error I am confused!
by kcott (Archbishop) on Jan 04, 2021 at 01:48 UTC

    G'day traincity,

    I suspect you're doing something like this:

    my $dbh = DBI->connect(...); my $sth = $dbh->prepare(...); ... $dbh->finish();

    As already pointed out by others, you probably don't need to use finish(). Please read the relevant documentation: "DBI: finish".

    If, after reading the documentation, you decide that you do need to use finish(), it should be written like this:

    $sth->finish();

    You've been asked to show us your code more than once. Kindly ensure you do this before asking any further questions. As it is, we're working in the dark and just making guesses.

    — Ken

Re: DBI::db error I am confused!
by Bod (Parson) on Jan 03, 2021 at 21:19 UTC

    From the documentation:
    "You almost certainly do not need to call this method."

    If as you say, the code works elsewhere, my best guess would be that you are using the wrong DB driver for the database you are using. But it's impossible to know for sure without knowing anything about the database and not seeing your code.

      Thank you... That is very helpful about the wrong db driver. The on-line running script is using mysql mariadb. I am using mysql workbench on the localhost. I doubt very much that it has anything to do with script or the data. Can anyone give me a hint how to change the driver? I have no idea. Thanks again!

        You're just guessing. Show us the code as 1nickt suggested.

        Can anyone give me a hint how to change the driver?

        The driver is passed to DBI as the first part of the first parameter of the connect method:

        use DBI; use DBD::mysql; my $dbh=DBI->connect("dbi:mysql:$database_schema:localhost:3306",$user +,$pass);
        This is connecting to MySQL which also works for MariaDB. Although there is a DBD::MariaDB but I haven't switched to using it yet.

        I am using mysql workbench on the localhost

        erm...you do know that MySQL Workbench isn't a database don't you???

Re: DBI::db error I am confused!
by Anonymous Monk on Jan 04, 2021 at 16:40 UTC
    I will safely bet (1) that you are calling the method against a database connection, and (2) that you don't need to.
      I'm not calling anything. I didn't write this program, I bought it a number of years ago. I am not well versed in perl. I had a guy who was helping me with things who I trusted but he disappeared. Have actually been running this for almost 20 years with bunch of bug fixes etc. But yet it runs successfully every day on-line. I haven't changed anything in the script for localhost other than the shebang and had to fix some paths. My problem is trust. Who can I trust to help me? I mean I ask a serious question about a problem I'm having and some obnoxious guy mocks me? That's real helpful! I know under normal circumstances you would send script. But then what script do I send? Why would a program work with mariadb and not workbench? I really think it has something to do with that, not script. Sorry for the tantrum, but this is a frustrating experience.
        "Sorry for the tantrum, but this is a frustrating experience."

        It's equally as frustrating for us. I mean you have been asked at least twice to show the relevant software code so that we can help you, but instead of doing that in order to get help, you go on a rant.

        Many of us here have been programming in Perl for decades, and have been on this site just as long helping Perl users with coding problems. Thing is, to resolve a coding problem, we kind of need to see code.

        Once again, please post the relevant code that's triggering the problem, and some of the surrounding context as well.

        "I really think it has something to do with..." ...there you go guessing again. Stop guessing at what you have no idea about. Show code so we can help you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11126230]
Approved by 1nickt
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-19 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found