Perl DBI without accessing the database

前端 未结 6 1937
悲哀的现实
悲哀的现实 2021-01-18 16:08

I\'m creating a set of SQL INSERT statements for a database that doesn\'t exist yet, and I\'m saving them to file.

How can I use Perl\'s powerful DBI m

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 16:33

    Usually you would use DBI by specifying a database like so:

    my $dbh = DBI->connect("DBI:mysql:database=$db_name;host=127.0.0.1");
    

    However, your database does not yet exist so you cannot connect to it. You can use DBI without specifying a database like so:

    my $dbh = DBI->connect("DBI:mysql:;host=127.0.0.1");
    

提交回复
热议问题