Perl DBI without accessing the database

前端 未结 6 1941
悲哀的现实
悲哀的现实 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:48

    According to perl -MDBI -E 'say join(q{,},DBI->available_drivers);' in clean Debian chroot with only DBI (package "libdbi-perl") installed the following drivers are available right away:

    DBM,ExampleP,File,Gofer,Proxy,Sponge
    

    The minimum DBI connect statement that works for me is

    my $dbh=DBI->connect("DBI:DRIVER:");  # DRIVER is one of [DBM,File,ExampleP,Sponge,mysql,SQLite]
    

    That is enough to use $dbh->quote() with no database whatsoever.

    DBM and File escape q{'} as q{\'} ("mysql" style);
    ExampleP and Sponge escape: q{'} as q{''} ("SQLite" style).

提交回复
热议问题