PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > Perl
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools
Old 4-18-03, 03:23 PM   #1
prp
Guest
 
Posts: n/a
Perl test script to create tables

Hello,

Is there a simple Perl script for making tables that I can use to test my installation and configuration? If there is, please send the code with instructions and expected results.

I'm assuming (not sure) that DBI and drivers are already installed in ns3.powweb.com for mysql02.powweb.com and the script should be set to chmod 755.

Thanks,
prp

Last edited by prp; 4-18-03 at 03:34 PM..
 
Old 4-19-03, 03:27 AM   #2
netaustin
Guest
 
Posts: n/a
you assume correctly. both DBI and the mysql driver are installed on all powweb webservers. however, you'd be using the script on your webserver, not a nameserver or a dbserver. webservers provide the link between the data source (mysql02 in this case) and the end user.

if you want to perform diagnostics or operations of any sort on your database, i suggest mysql front or phpMyAdmin.

try this:

#!/usr/bin/perl

print "Content-type: text/html\n\n";

use DBI;
$db="yourdatabase";
$host="mysql02.powweb.com";
$port="3306";
$user="username";
$pass="password";
$info="DBI:mysql:database=$db;$host:$port";

$dbh = DBI->connect($info,$user,$pass);

$query = "create table tablename (fieldname datatype(value), fieldname datatype(value))";

$sth = $dbh->prepare($query);
if $sth->execute() print "<br>It worked</br>";
$sth->finish();

$dbh->disconnect;

you need to edit this to reflect your database settings and the table you want to creat with its types and default values.
 
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:42 AM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.