in reply to Re: DBI Problem
in thread SOLVED: DBI Problem

Yes, I did. Here's the DBI connect line:
my $dbHandle = DBI->connect($dbSource, $dbUserName, $dbPassword, {Rais +eError => 1, AutoCommit => 0});
As for credentials, I'm connecting to the DB both in code and through the SQL console with 'root' user.. So unless there's some other specific credentials being used by the SQL console.... But.. if it was a credentials issue, shouldn't DBI be returning an error, not suggesting that 1 row was affected?

Replies are listed 'Best First'.
Re^3: DBI Problem
by erix (Prior) on Jan 29, 2018 at 19:58 UTC

    AutoCommit => 0

    means you have to explicitly call $dbh->commit or your changes will be rolled back.

      Yes! Thank you! I should've seen that sooner.. But I guess I figured that was fine because other queries have worked..

      Now my new question is, how did it ever work for my previous calls?

      Previously, I was running a script that did Create tables statements and Insert Statements.

      I had to put the Insert statements first or I had the same problem..

      So does that mean Create table statements force a commit to the DB even if Autocommit is 0 and I never explicitly called commit?

        So does that mean Create table statements force a commit to the DB even if Autocommit is 0 and I never explicitly called commit?

        Try it and see. I suppose it makes sense; CREATE TABLE is DDL; INSERT is DML; and only some databases (PostgreSQL, for instance) know how to do transactional DDL.

        Transactional DDL example:

        # begin; --> start a transaction create table testtable(id serial, c text); --> ... and create a tabl +e BEGIN CREATE TABLE # insert into testtable (c) values ('this will be short-lived'); --> +insert a row INSERT 0 1 # select * from testtable; --> have a look id | c ----+-------------------------- 1 | this will be short-lived (1 row) # rollback; --> go back to initial state before begin ROLLBACK # select * from testtable; --> now the table is gone... ERROR: relation "testtable" does not exist LINE 1: select * from testtable; ^

        You get the idea...

        Update: added a DDL transaction begin-create-rollback session.