Databases On The Web with perl Archie Warnock

Slides:



Advertisements
Similar presentations
Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Adding Dynamic Content to your Web Site
Murali Mani SQL-PL Interface. Murali Mani Some Possible Options Web Interface Perl /CGI with Oracle/mySQL Install your own web server and use servlets.
W EB A PPLICATION D EVELOPMENT A PPLICATION T O B IO -I NFORMATICS -III Vicky Khanna M-Tech Bioinformatics.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
-Dynamic Web Pages 데이타베이스 연구실 홍 동 숙. Product HTML is static but CGI and Web server APIs aren ’ t –Using HTML, The text and the format of its display remain.
Introduction to Active Server Pages
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #21 M.P. Johnson Stern School of Business, NYU Spring, 2005.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
Set 5: Perl and Database Connections
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
3/8/00asp00 1 Active Server Pages from Microsoft Nancy McCracken Northeast Parallel Architectures Center at Syracuse.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
Student Learning Environment on the World Wide Web l CGI-programming in Perl for the connection of databases over the Internet. l Web authoring using Frontpage.
27/07/2001 Copyright 2001, Munica Corporation, 1 How to write a DBD driver Daini Xie Strathy President Munica Corporation
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
DBI tutorial February 5 th, What is DBI DBI is short for Database Interface, which is a Perl module DBI is short for Database Interface, which is.
Information & Decision Management Dept West Texas A&M University
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
A Web-Enabled Aircraft Scheduler Michael Wallette 20 Nov
Applied Research Laboratory UNCLASSIFIED IOUW 2000 Managing Oracle and Other Cool Things You Can Do with PERL John D. Groenveld Manufacturing Systems Division.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Team Members Team Members Tim Geiger Joe Hunsaker Kevin Kocher David May Advisor Dr. Juliet Hurtig November 8, 2001.
Templates, Databases and Frameworks. Databases: DBI Common database interface for perl Provides a functional,
– Introduction to CGI 4/8/ Introduction to CGI Introduction to CGI – Session 2 · Introduction to CGI:  Generating.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
A Brief Documentation.  Provides basic information about connection, server, and client.
How to create a simple Web application with CGI::Application Template::Toolkit and DBIx::Class Leonard Miller February 7, 2009.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Java, JDBC, Perl, CGI Embedded SQL November 3 rd, 2000.
Intermediate CGI & CGI.pm Webmaster II - Fort Collins, CO Copyright © XTR Systems, LLC CGI Programming & The CGI.pm Perl Module Instructor: Joseph DiVerdi,
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Four Instructor:
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Three Instructor:
WEB SERVER SOFTWARE FEATURE SETS
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
DBI: The Neophyte's Guide1 What is DBI? DBI = DataBase Interface DBI is database-independent DBI allows you to write code that interacts with databases.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
COMP234 - perl Perl DBI Topics Database vs access methods DBMS and DBMS API's Relational database SEQUEL Perl DBI SQL.
Revision Lecture: HTML, CSS and XML Perl/CGI, Perl/DOM, Perl/DBI, Remote Procedure Calls Dr. Andrew C.R. Martin
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Internet/Web Databases
Introduction to Dynamic Web Programming
Relational database and SQL MySQL LAMP SQL queries
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP / MySQL Introduction
Database Driven Websites
Perl Database – Just Enough
Introduction to NetDB2 IST210.
Web Application Development Using PHP
Presentation transcript:

Databases On The Web with perl Archie Warnock

Arbitration System Overview The Task: Build an online legal case management system with a Web interface The Client: An Intergovernmental Organization with little IT experience Subsystems include: 4Users, Cases, Documents 4Parties to Case 4Panel of judges 4Case Manager 4Financial

Requirements Web interface for filing complaints - submit evidence, edit submitted information, make financial arrangements High security and confidentiality Web-based interface for case management Report generation for judges, arbitration center staff

Architecture

Getting Started with perl DBD The Toolbox: 4Linux 4perl 5 4An SQL or ODBC database for Linux - Oracle, MySQL, mSQL, … 4DBI/DBD modules & utilities 4CGI.pm module 4Text::Template module

Session Overview Connect to database server Do some database stuff Print results into a template Disconnect from database server

Client Configuration # You can load this in a module if ($DB eq $oracle) { $ENV{ORACLE_HOME} = '/ '; $ENV{ORACLE_SID} = ’ORCL'; $ENV{TWO_TASK} = ’ORCL'; $connect_str ="dbi:$oracle:"; } elsif ($DB eq $mysql) { my $database = “dbname"; my $server = “hostname"; my $port = “port"; $connect_str ="DBI:$mysql:$database:$server:$port"; } else { foo; }

The Database Connection sub connectToDB { # Make the connection # Username and password are stored separately $dbh = DBI->connect( $main::connect_str, $main::dbuser, $main::dbpass) or die print "Failed to connect to database server ". $DBI::errstr ; return $dbh; }

Connect To Database Server Now, open the connection by calling: $dbh = connectToDB(); Keep track of $dbh - it is the handle for the database connection It will stay active for a single CGI connection, but it doesn’t seem to be worth the trouble to maintain it across sessions

Do Some Database Stuff - 1 Non-select statement, single row result $language = ‘perl’; $language = $dbh->quote($language); $sql = qq[INSERT INTO compilers (language) VALUES ($language)]; $result = $dbh->do($sql); if ($result != 1) { # Some error handler here } $dbh->disconnect();

Do Some Database Stuff - 2 Select statement, single row result $language = ‘perl’; $language = $dbh->quote($language); $sql = qq[ SELECT price FROM compilers WHERE language = $language]; $result = $dbh->selectrow_array($sql);

Do Some Database Stuff - 3 Select statement, multiple row result $language = ‘perl’; $language = $dbh->quote($language); $sql = qq[ SELECT * FROM compilers]; $sth = $dbh->do($sql); while = $sth->selectrow()) { # some processing, row-by-row }

Fancy Database Stuff Variable bindings for repeated statements $sth = $dbh->prepare("insert into table(foo,bar,baz) values (?,?,?)"); while( ) { chop; my ($foo,$bar,$baz) = split /,/; $sth->execute($foo,$bar,$baz); }

Print Results Results are returned in a row, so you can paste them into a table Use Text::Template to insert dynamic HTML into static HTML sub PrintRedirect { use Text::Template; no strict; disable diagnostics; $Title = shift; $Heading = shift; $template = new Text::Template( TYPE => FILE, SOURCE => "$main::docroot/logout.tmpl"); print header(-refresh=>"10; URL=$main::BaseCGI/Login", -type=>'text/html'); $text = $template->fill_in(OUTPUT => \*STDOUT); }

A Real Example - perl sub PrintComplainantList { use Text::Template; no strict; disable diagnostics; $session = shift; $template = new Text::Template( TYPE => FILE, SOURCE => "$main::docroot/parties.tmpl"); # get the list of respondents by case number $dbh = &Database::connectToDB(); if ($dbh) { $CaseNo = $dbh->quote($caseno); $sql = qq[ SELECT user_id, , last FROM claimant_cases WHERE case_id = $CaseNo];

A Real Example - More perl $sth = $dbh->prepare($sql); $sth->execute; $NumberOfRows = = ""; while = $sth->fetchrow_array) { # Grab the results, row-by-row $row_head = " $row_head "; $NumberOfRows++; } &Database::disconnectFromDB($dbh);

Real Example - HTML Template { $title } { $heading } <form method="post" action="{ $BaseCGI }/NewCaseMenu"> <input type="hidden" name="Session" value="{ $session }"> <input type="hidden" name=”Case" value="{ $caseno }"> { ($NumberOfRows)? $foo='' : $foo=TR([th({- $foo }

Summary perl is (of course) a superb prototyping and production tool Interfaces to existing databases are easy to build, run well CGI.pm allows simple scripting Text::Template allows you to use site management tools like FrontPage, DreamWeaver to maintain consistency