classes:general:dbsamples:perl_mysql
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| classes:general:dbsamples:perl_mysql [2020/10/23 22:46] – localadmin | classes:general:dbsamples:perl_mysql [2021/09/17 22:27] (current) – localadmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Perl example for MySQL database connection ====== | ||
| + | |||
| < | < | ||
| use strict; | use strict; | ||
| Line 17: | Line 19: | ||
| $db_conn_string = " | $db_conn_string = " | ||
| - | # Connect to db on Hrothgar | + | # Connect to db | 
| if ($conn = DBI-> | if ($conn = DBI-> | ||
| { | { | ||
| # Prepare and execute an SQL statement | # Prepare and execute an SQL statement | ||
| - |   $stmt = $dbh-> | + |   $stmt = $conn-> | 
| - |                           | + | FROM table_name | 
| - |                           | + |                           WHERE table_name.field=something" | 
|   $stmt-> |   $stmt-> | ||
| - |   # retrieve  | + |   # Retrieve  | 
| print "Query Output \n"; | print "Query Output \n"; | ||
| Line 36: | Line 38: | ||
| else | else | ||
| { | { | ||
| - |   # Couldn' | + |   # Error!  | 
| } | } | ||
| </ | </ | ||
classes/general/dbsamples/perl_mysql.1603493195.txt.gz · Last modified:  by localadmin
                
                