1

I tried installing DBD-SQLite-0.31 module from CPAN. I have downloaded DBD-SQLite-0.31 from CPAN. I tried installing it and it gave me an error of pre-requisite DBI module isn't there.

I had installed DBI module from CPAN and then installed DBD-SQLite-0.31.

When I tried running the perl statement use DBI DBD::SQLite;, it gave a error

"DBD::SQLite" is not exported by the DBI module
Can't continue after import errors at DBI.txt line 3
BEGIN failed--compilation aborted at DBI.txt line 3.

Why did the error happened?

When I tried to debug it, I found that to run the statement use DBI DBD::SQLite;, DBD::SQLite needs to be in DBI directory, but both are in separate directories. I even copied the DBD::SQLite in DBI folder but the issue remains same. (These are all my wild guesses)

2
  • You need 2 seperate use statements for both DBI and DBD::SQLite. You cant import in one, thats incorrect syntax.
    – user966588
    Commented Jan 27, 2014 at 14:51
  • 1
    @DA14, you don't need a use statement for DBD::SQLite at all. It gets loaded automatically by DBI when you connect to a SQLite database.
    – cjm
    Commented Jan 27, 2014 at 16:12

3 Answers 3

4

Statement use DBI is what you want.

Anything after the module name is passed as arguments to import method of imported module.

1
  • 4
    Because 'DBD::SQLite' is not an valid argument for the import method. In most cases you provide a list of subs which should be imorted in your current namespace.
    – gensym
    Commented Jan 27, 2014 at 13:34
4

I don't know where you got the idea to try loading it like that, but in general if you're not sure how to use a module you need to look at its documentation on CPAN.

In this case it's really simple: https://metacpan.org/pod/DBD::SQLite#SYNOPSIS

3

What is happening is that you shouldn't mention multiple Modules in a single use statement. Extra information on the use line can include a minimum version number for the module or a list of items that the module should export. perldoc -f use for the gory details...

In general you'll not want to explicitly use DBD::SQLite;. It will generally be loaded by implicit mention in the 1st parameter of DBI->connect().

1
  • Please don't use unnecessary parens after either method or function calls. It is good Perl style to leave them out whenever possible and only use them when the Perl parser can't recognise what you're trying to do.
    – Mithaldu
    Commented Jan 27, 2014 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.