Home: Perl Programming Help: DBI:
Which DBI to use for this project?



miniCruzer
Novice

Oct 8, 2010, 5:33 PM


Views: 6513
Which DBI to use for this project?

A few friends and I are writing an IRC Bot in Perl, and want to incorporate a database file. At the moment, its using text files to read and write, which can become very slow when reading large databases. We need something that is quick, and light (not bucketloads of code).

The database (as of now) includes 4 keys, that are: Channel, Admin, Owner, "ATS".

Channels are prefixed with "#". Admins are prefixed with "A:", Owners are prefixed with "O:", and "ATS" is prefixed with "ATS".

For example, if someone adds a channel runtime, it writes that channel to the database, as

Code
C:#NewChannel

If someone adds an ATS command, it writes as

Code
ATS:Call:Response can be more than 1 word

It deletes these keys by matching with the prefix, and loads the keys for runtime use with prefixes into arrays and/or hashes.

It would be nice to be able to attach extra data to these values, perhaps in the following way:

Code
channels { 
"#chan1" {
createdby = "user",
createdon = "date",
bans = {
"*!*@host1.com",
"*!*@host2.com",
},
autoop = {
"this!user@*",
"thisother!user@*",
},
"#chan2" {
createdby = "user",
createdon = "user",
modes = "tnsirz",
},
}



FishMonger
Veteran / Moderator

Oct 9, 2010, 7:54 AM


Views: 6506
Re: [miniCruzer] Which DBI to use for this project?

DBI - Database independent interface for Perl
http://search.cpan.org/~timb/DBI-1.615/DBI.pm

DBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)
http://search.cpan.org/~capttofu/DBD-mysql-4.017/lib/DBD/mysql.pm

Tie::Hash::DBD, tie a plain hash to a database table
http://search.cpan.org/~hmbrand/Tie-Hash-DBD-0.07/lib/Tie/Hash/DBD.pm

Tie::DBI - Tie hashes to DBI relational databases
http://search.cpan.org/~toddr/Tie-DBI-1.05/lib/Tie/DBI.pm


(This post was edited by FishMonger on Oct 9, 2010, 7:56 AM)


miniCruzer
Novice

Oct 10, 2010, 1:20 PM


Views: 6466
Re: [FishMonger] Which DBI to use for this project?

Thanks for the reply. SQLite seems to be doing the trick, though!


FishMonger
Veteran / Moderator

Oct 10, 2010, 1:28 PM


Views: 6464
Re: [miniCruzer] Which DBI to use for this project?


In Reply To
Thanks for the reply. SQLite seems to be doing the trick, though!


Do you mean DBD::SQLite - Self-contained RDBMS in a DBI Driver http://search.cpan.org/~adamk/DBD-SQLite-1.31/lib/DBD/SQLite.pm?
Since your opening post didn't say which database you were using or planning on using, I couldn't be sure which DBD module to point out.