diff --git a/mysql/examples/dbtrainer0 b/mysql/examples/dbtrainer0 index 74be9bf..e560925 100644 --- a/mysql/examples/dbtrainer0 +++ b/mysql/examples/dbtrainer0 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/ __version__ = "$Revision$"[11:-2] @@ -6,19 +6,19 @@ __version__ = "$Revision$"[11:-2] # Original credits follow. This is a nice introduction in general, # but I felt there were a few bits and pieces that needs to be cleaned up. -# TITLE: dbtrainer0 -# WRITTEN BY: Bradley Stec, July 1999 +# TITLE: +# WRITTEN BY: Bradley Stec, July # RuleSpace, Inc. -# SUPPORTS: WebOps Database Interface Trainer Script -# PURPOSE: This script is an code and output example of how to use the -# MySQLdb API to communicate with a database and perform basic +# SUPPORTS: WebOps Database Interface Trainer +# PURPOSE: This script is an code and output example of how to use +# MySQLdb API to communicate with a database and perform # SQL queries. # FUNCTION: Both by executing the script and by reading the source code, -# a programmer should be able to get a grasp on how the interface +# a programmer should be able to get a grasp on how the # works and may borrow code for their own script projects. -# REQUIREMENTS: This script requires the access to the webops module, and that a +# REQUIREMENTS: This script requires the access to the webops module, and that # database named "TEST" be installed in the webops specified -# database server. The contents of the test database can be created +# database server. The contents of the test database can be # using the following SQL command sets. # # CREATE TABLE COLORS ( @@ -59,16 +59,16 @@ __version__ = "$Revision$"[11:-2] # INSERT INTO TEAM VALUES (3,'Brittney','McChristy','The Data Diva','blue',NOW(),NOW()); # INSERT INTO TEAM VALUES (4,'Fuzzy','Logic','The Logic Bunny','cyan',NOW(),NOW()); # -# CHANGES: 7/99 Initial Version +# CHANGES: 7/99 Initial -import sys -#import webops -import traceback -sys.stderr = sys.stdout +import +#import +import +sys.stderr = sys. -# Set Up Page Layout +# Set Up Page print "content-type: text/html" -print + print "\n" print "
\n" print "RuleSpace, Inc. WebOps Database Interface Trainer - Part 0" print "
" print "
"
print "QUERY OF TEAM TABLE
"
print "("
-# The Table Field Names
+# The Table Field
for cursorFieldname in cursor.description:
print cursorFieldname[0]+","
print ")"
print "
"
-# The Result Set
+# The Result
for cursorRecord in resultSet:
- print cursorRecord
+ print
print "
"
print ""
@@ -174,14 +174,14 @@ for cursorRecord in resultSet:
print "
"
-# HERE'S ANOTHER TABLE
+# HERE'S ANOTHER
try:
cursor.execute("SELECT * FROM COLORS")
except:
@@ -198,11 +198,11 @@ print "
"
# The values are loaded into the object 'resultSet'
resultSet = cursor.fetchall()
for cursorRecord in resultSet:
- print cursorRecord
+ print
print "
"
print "
"
-# Display Query Results In Columns
+# Display Query Results In
print "same results in very nicely formatted columns:
"
print "
"
print ""
print " "
for cursorFieldname in cursor.description:
@@ -212,15 +212,15 @@ for cursorRecord in resultSet:
print " "
for cursorField in cursorRecord:
print " "
print ""
- print cursorField
+ print
print " "
print "
"
-# NOW WE CAN SEE HOW TO COMBINE KEYED TABLES
-# The following query uses standard SQL commands to join the two databases together and produce a list of each of the team's
+# NOW WE CAN SEE HOW TO COMBINE KEYED
+# The following query uses standard SQL commands to join the two databases together and produce a list of each of the team'
# favorite colors.
try:
cursor.execute("SELECT TEAM.FIRST_NAME,TEAM.LAST_NAME,TEAM.FAV_COLOR,COLORS.PRIME_COLOR FROM TEAM,COLORS WHERE TEAM.FAV_COLOR = COLORS.COLOR")
@@ -242,14 +242,14 @@ for cursorRecord in resultSet:
print "
" -# CLOSING THE DATABASE OBJECT +# CLOSING THE DATABASE try: WebOpsDB.close() except: @@ -257,10 +257,10 @@ except: traceback.print_exc() sys.exit() -# CONTINUED IN DBTRAINER1 -# To learn more about inserting records, and performing other SQL functions review +# CONTINUED IN +# To learn more about inserting records, and performing other SQL functions # dbtrainer1. -# END YOUR HTML PAGE +# END YOUR HTML print "\n" print "\n" diff --git a/mysql/examples/dbtrainer1 b/mysql/examples/dbtrainer1 index 7483c1e..6057240 100644 --- a/mysql/examples/dbtrainer1 +++ b/mysql/examples/dbtrainer1 @@ -52,7 +52,7 @@ import MySQLdb # This command forms a connection through the support files to the target database server and database name. try: #WebOpsDB = MySQLdb.Connection(host=webops.dbserver,user=webops.dbuser,passwd=webops.dbpass,db='test',port=3306,unix_socket="") - WebOpsDB = MySQL.Connect(db='test') + WebOpsDB = MySQLdb.Connect(db='test') except: print "\n\n
" traceback.print_exc() diff --git a/mysql/examples/dbtrainer4 b/mysql/examples/dbtrainer4 index f9654e7..8b3ec19 100644 --- a/mysql/examples/dbtrainer4 +++ b/mysql/examples/dbtrainer4 @@ -23,7 +23,7 @@ __version__ = "$Revision$"[11:-2] # CHANGES: 7/99 Initial Version import sys -import webops +#import webops import traceback sys.stderr = sys.stdout