Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can perl use an MS Access DB for data? 1

Status
Not open for further replies.

iSeriesCodePoet

Programmer
Jan 11, 2001
1,373
US
I want to create a site that holds bookmarks, and I want to be able to add, change, and maybe delete the bookmark. However, I am going to be using a free site to host this, so I don't know what OS it is running on. Can I use a MS Access DB to do this? Or will I have to use a text file? I have little to no knowledge of Perl (this is going to be my learning experience), but I am a programmer.

Any help will be appreciated...


Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
Chances are you will have to use a text file, or possibly a DBM file. Most ISPs use *nix operating systems, and you won't find an MS Access DB on them. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
What is a DBM file? Is it something designed for use with perl? How do I create one?

This was my thoughts on DB layout:
Parent > Child 1 > Child 2 > .... Child n
I haven't decided how to exactly lay this out yet.
Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
A DBM file is basically a perl hash that is stored in a disk file. That means you only have one key and one data string for each record. It's not great, but sometimes it's better than flat files. You can use the perl DBM modules from CPAN ( to access them. There's a good possibility that your ISP already has the DBM modules installed. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
DBI is the standard perl interface to databases - check out the Perl database FAQ in this forum to find out where you can get the modules. I believe you can use DBD::ODBC to connect to an MS Access database, but I haven't done that myself - I'm on Linux and have experience with MySQL and Oracle, but not with MS Access, and I haven't used DBD::ODBC.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
To create a simple DBM:

dbmopen(%data, "database_name", 0644);
$username = "something";
$email = "email_value";
dbmclose(%data);

to read a DBM:

dbmnopen(%data, "database_name", 0644);
print "Hello, $username with the email $email";
dbmclose(%data);

If you are using DBM, then the spaces are now limited. Meaning, if you keep both keys and values down to 1000 binary characters or less, you'll be allright:).
 
Would you be happy using a different database platform? MySQL is free, multi-platform, and may suit your needs a bit better.. it's supported by DBI (Database Independent) as well. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Thanks AaronGeorge for the example!

imotic, I would if I could. Do you know of any free hosting sites that provides a free MySQL database? Eventually I will have to move to a paid site, but I don't what to do it now (since my site isn't even made yet, one year later). Thus why I asked about M$ Access.
Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
The above example will not work. Once a DBM file is opened it is tied to the hash named as the first parameter (in the example %data). In order to create a record you need to do something like this:
Code:
$data{$username} = $email;
Similarly, in order to read data from the hash you need to either reference a specific key value from the hash, or iterate over all the key values likes this:
Code:
foreach $username (keys %data) {
   print &quot;User $username has email $data{$username}\n&quot;;
]
Note, however, that according to the perl man pages the dbmopen function has been largely superceded by the tie function. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
You can in fact use Perl to access an MS Access dataase but I believe that these other learned Perl gurus are right. If you are using a free hosting site then there isn't any way they are going to allow you to host a database of any kind on their servers. (Besides Access is horrible. mySQL would be my suggestion if you are leaning toards a dataase.) For what you are suggesting a DBM file is your best bet. Depending on who you are hosting with I would be surprised if they even allow you to use Perl. For instance you can't use Perl with Yahoo or Angelfire.
 
MySQL is cheaper (by virtue of being free) than MS Access... what free hosting site will give you an MS Access database to work with? <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
I haven't researched everything yet. I have to take a look at what I can and can't do on the site yet. (If only I could get DSL) I will probably have to get a pay site to do what I want. I am just starting on the research part of developing it. Thanks everyone for the help.
Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
I would say that if you are going to do a pay site, then for $20/month or less you can have access to Perl. I pay less than 20 for my site complete with Perl, and thats in Canada. I know for database hosting it can start at around the $50/month mark. What I did temporarily is host my ste for $20 and then had my database hoste at my house on my cable modem and I just pointed to it remotely. Depending on your hardware it might be a security risk for you though. May I ask what kind of data you are storing? I am a db developer by design so I might be able to help you sort out an efficient way of dealing with it.
 
The one problem with that theory is that I have a dial-in connection. If I had DSL/Cable I would just host it on my server and forget about any hosting site.

All the data is bookmarks (Title, Link, Short Description). The only security I would like is that no one but me can change/delete them. As I have stated before, I am still figuring out how I want to do this. I am going to try to get a more realistic thing to do rather than go through all the stupid exercises in the Perl Cookbook.
Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
I've been reading this from the top, and can't add much to the DB debate, but......... although their servers can be a bit slow sometimes, I have had a fairly good experience with
They are based where I am in London and included free is;-
15mb, Full CGI access (great support for Perl), mySQL, PHP, no banners or adverts and free domain parking / forwarding.

I had a site with them for a year and I put a client i worked with on there and if you can compromise speed for cost (or just wanted another test server like i did), they're worth a look. and FYI they use AS400 machines.

As for the DB disscussion, I don't know that much about databases but I agree with trying to avoid Access if possible. I have used SQL, mySQL and Access and I've found SQL (any flavour) is much better and easier (because unlike any MS stuff - it usually works!!).

Hope this helps.

Jez :)
 
Hey...I wonder if I can get an AS400 account from them...then I wouldn't have to touch Perl. I could write in RPG, my language of choice.
Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
Write in RPG? Are you *MAD*? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
No...I am quite quick when it comes to writing programs in RPG. Plus I know how I would write it in RPG. It too is quite powerful. But enough about RPG...this is the Perl forum. I will start a new thread when it gets closer to when I want to do this in Perl, I would guess I can do it close to the same way in Perl as in RPG, I shall have to do more research.....



Mike Wills
IT Corporate Support (aka iSeries Progammer)
koldark@koldark.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top