#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" % MySQL tests 3 X v1 MySQL tests U Lucida Grande cREVGeneral scriptChecksum ُ B~ debugObjects bookmarks handlerList scriptSelection char 1 to 0prevHandler tempScript script
Pon clearAll put "" into fld "db ID" put "" into fld "Table ID" put "" into fld "Tables" put "" into fld "Desc ID" put "" into fld "Describe" put "" into fld "Select ID" put "" into fld "Select" put "" into fld "Select headers" put "" into fld "SQL" put "" into fld "Query" put "" into fld "Exec result" put "" into fld "New headers" put "" into fld "New record" put "" into fld "Counter" end clearAll function getConnectID put fld "db ID" into dbID if dbID is empty then send mouseUp to btn "Connect" put fld "db ID" into dbID if dbID is empty then beep answer error "Can't connect to database." return "" end if end if return dbID end getConnectID 1 cREVGeneral scriptChecksum OғA>)" bookmarks handlerList clearAll getConnectIDtempScript prevHandler clearAllscriptSelection char 242 to 241scripton clearAll
put "" into fld "db ID"
put "" into fld "Table ID"
put "" into fld "Tables"
put "" into fld "Desc ID"
put "" into fld "Describe"
put "" into fld "Select ID"
put "" into fld "Select"
put "" into fld "Select headers"
put "" into fld "SQL"
put "" into fld "Query"
put "" into fld "Exec result"
put "" into fld "New headers"
put "" into fld "New record"
put "" into fld "Counter"
end clearAll
function getConnectID
put fld "db ID" into dbID
if dbID is empty then
send mouseUp to btn "Connect"
put fld "db ID" into dbID
if dbID is empty then
beep
answer error "Can't connect to database."
return ""
end if
end if
return dbID
end getConnectID
$ % ! " # db path i` f cREVGeneral scriptChecksum ُ B~ bookmarks revUniqueID 1030147405748handlerList scriptSelection char 1 to 0prevHandler mouseUptempScript script db ID ` : cREVGeneral revUniqueID 1030147416060 Connect Epon mouseUp put fld "db user" into dbUser put fld "db pass" into dbPass put fld "db path" into dbName put fld "db address" into dbAddr if dbAddr is empty then put "localhost" into dbAddr put revOpenDatabase("MySQL",dbAddr,dbName,dbUser,dbPass) into dbresult if dbresult is a number then put dbresult into fld "db ID" else answer dbResult end if end mouseUp ' d cREVGeneral scriptChecksum ws[BƩ.uz bookmarks revUniqueID 1030147470687handlerList mouseUpscriptSelection char 385 to 384prevHandler mouseUptempScript scripton mouseUp
put fld "db user" into dbUser
put fld "db pass" into dbPass
put fld "db path" into dbName
put fld "db address" into dbAddr
if dbAddr is empty then put "localhost" into dbAddr
put revOpenDatabase("MySQL",dbAddr,dbName,dbUser,dbPass) into dbresult
if dbresult is a number then
put dbresult into fld "db ID"
else
answer dbResult
end if
end mouseUp
New Field 1 d cREVGeneral revUniqueID 1030148627680 Database name: New Field 1 _ cREVGeneral revUniqueID 1030148627680 Connection ID: Close Ep on mouseUp put revOpenDatabases() into connectList repeat for each item c in connectList revCloseDatabase c end repeat clearAll end mouseUp ' ) d cREVGeneral scriptChecksum &S6aKV뛓/Q bookmarks revUniqueID 1030148514095handlerList mouseUpscriptSelection char 129 to 128prevHandler mouseUptempScript scripton mouseUp
put revOpenDatabases() into connectList
repeat for each item c in connectList
revCloseDatabase c
end repeat
clearAll
end mouseUp
List tables Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put "SHOW TABLES;" into dbQuery put revQueryDatabase(dbID, dbQuery) into curID put curID into fld "Table ID" if curID is not a number then answer error "Query failed:" & cr & curID exit mouseUp end if put revNumberOfRecords(curID) into recNum put revDatabaseColumnCount(curID) into colNum put empty into fld "Tables" revMoveToLastRecord curID repeat recNum times repeat with c = 1 to colNum put revDatabaseColumnNumbered(curID, c) & cr before fld "Tables" end repeat revMoveToPreviousRecord curID if the result = false then exit repeat end repeat delete last char of fld "Tables" revCloseCursor curID end mouseUp ~ d cREVGeneral scriptChecksum պ'3!q=`"breakPoints handlerList mouseUpscriptSelection char 83 to 82revUniqueID 1030148799372 bookmarks tempScript prevHandler mouseUpscripton mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put "SHOW TABLES;" into dbQuery
put revQueryDatabase(dbID, dbQuery) into curID
put curID into fld "Table ID"
if curID is not a number then
answer error "Query failed:" & cr & curID
exit mouseUp
end if
put revNumberOfRecords(curID) into recNum
put revDatabaseColumnCount(curID) into colNum
put empty into fld "Tables"
revMoveToLastRecord curID
repeat recNum times
repeat with c = 1 to colNum
put revDatabaseColumnNumbered(curID, c) & cr before fld "Tables"
end repeat
revMoveToPreviousRecord curID
if the result = false then exit repeat
end repeat
delete last char of fld "Tables"
revCloseCursor curID
end mouseUp
Table ID ` H cREVGeneral revUniqueID 1030149305310 Describe table Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put the hilitedLine of fld "Tables" into lineNum if lineNum is empty then answer error "Please select a table." exit mouseUp end if put line lineNum of fld "Tables" into tableName put "DESCRIBE " & tableName & ";" into dbQuery put revQueryDatabase(dbID, dbQuery) into curID put curID into fld "Desc ID" if curID is not a number then answer error "Query failed:" & cr & curID exit mouseUp end if put revNumberOfRecords(curID) into recNum put revDatabaseColumnCount(curID) into colNum put empty into fld "Describe" lock screen revMoveToLastRecord curID repeat recNum times put empty into tRec repeat with c = 1 to colNum put revDatabaseColumnNumbered(curID, c) & tab after tRec end repeat put tRec & cr before fld "Describe" revMoveToPreviousRecord curID if the result = false then exit repeat end repeat delete last char of fld "Describe" revCloseCursor curID end mouseUp ~ d cREVGeneral scriptChecksum h7;X9ǫo bookmarks revUniqueID 1030148799372handlerList mouseUpscriptSelection char 659 to 658prevHandler mouseUptempScript script Ron mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put the hilitedLine of fld "Tables" into lineNum
if lineNum is empty then
answer error "Please select a table."
exit mouseUp
end if
put line lineNum of fld "Tables" into tableName
put "DESCRIBE " & tableName & ";" into dbQuery
put revQueryDatabase(dbID, dbQuery) into curID
put curID into fld "Desc ID"
if curID is not a number then
answer error "Query failed:" & cr & curID
exit mouseUp
end if
put revNumberOfRecords(curID) into recNum
put revDatabaseColumnCount(curID) into colNum
put empty into fld "Describe"
lock screen
revMoveToLastRecord curID
repeat recNum times
put empty into tRec
repeat with c = 1 to colNum
put revDatabaseColumnNumbered(curID, c) & tab after tRec
end repeat
put tRec & cr before fld "Describe"
revMoveToPreviousRecord curID
if the result = false then exit repeat
end repeat
delete last char of fld "Describe"
revCloseCursor curID
end mouseUp
Desc ID ` N H cREVGeneral revUniqueID 1030149305310 Execute Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put fld "SQL" into dbSQL if last char of dbSQL = ";" then delete last char of dbSQL revExecuteSQL dbID, dbSQL put the result into sqlResult if sqlResult is a number then put "Query OK: " & sqlResult & " record(s) altered." into fld "Exec result" else put sqlResult into fld "Exec result" end if end mouseUp d cREVGeneral scriptChecksum ׇBbb)"r\ bookmarks revUniqueID 1030151524841handlerList mouseUpscriptSelection char 414 to 413prevHandler mouseUptempScript script Ron mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put fld "SQL" into dbSQL
if last char of dbSQL = ";" then delete last char of dbSQL
revExecuteSQL dbID, dbSQL
put the result into sqlResult
if sqlResult is a number then
put "Query OK: " & sqlResult & " record(s) altered." into fld "Exec result"
else
put sqlResult into fld "Exec result"
end if
end mouseUp
Exec result ` R cREVGeneral revUniqueID 1030152681903 Select Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put fld "Query" into theSQL if theSQL is empty then answer error "Please enter a query." exit mouseUp end if if word 1 of theSQL is not in "SELECT,SHOW" then put "SELECT " before theSQL if last char of theSQL <> ";" then put ";" after theSQL put theSQL into fld "Query" put revQueryDatabase(dbID, theSQL) into curID if curID is not a number then put "Error" into fld "Select ID" put curID into fld "Select" exit mouseUp end if put curID into fld "Select ID" lock screen put revDatabaseColumnCount(curID) into colNum put empty into fld "Select" put revDatabaseColumnNames(curID) into colNames replace comma with tab in colNames put colNames into fld "Select headers" replace tab with cr in colNames put colNames into fld "New headers" put empty into fld "New record" put revNumberOfRecords(curID) into recNum put recNum into fld "Counter" -- revMoveToLastRecord curID if recNum > 0 then repeat recNum times put empty into tRec repeat with c = 1 to colNum -- put revDatabaseColumnNamed(curID, line c of colNames) & tab after tRec put revDatabaseColumnNumbered(curID, c) & tab after tRec end repeat put tRec & cr after fld "Select" -- revMoveToPreviousRecord curID revMoveToNextRecord curID if the result = false then exit repeat end repeat end if delete last char of fld "Select" revCloseCursor curID end mouseUp d cREVGeneral scriptChecksum ύ& P[VrevUniqueID 1030148799372 bookmarks handlerList mouseUptempScript prevHandler mouseUpscriptSelection char 1326 to 1325scripton mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put fld "Query" into theSQL
if theSQL is empty then
answer error "Please enter a query."
exit mouseUp
end if
if word 1 of theSQL is not in "SELECT,SHOW" then put "SELECT " before theSQL
if last char of theSQL <> ";" then put ";" after theSQL
put theSQL into fld "Query"
put revQueryDatabase(dbID, theSQL) into curID
if curID is not a number then
put "Error" into fld "Select ID"
put curID into fld "Select"
exit mouseUp
end if
put curID into fld "Select ID"
lock screen
put revDatabaseColumnCount(curID) into colNum
put empty into fld "Select"
put revDatabaseColumnNames(curID) into colNames
replace comma with tab in colNames
put colNames into fld "Select headers"
replace tab with cr in colNames
put colNames into fld "New headers"
put empty into fld "New record"
put revNumberOfRecords(curID) into recNum
put recNum into fld "Counter"
-- revMoveToLastRecord curID
if recNum > 0 then
repeat recNum times
put empty into tRec
repeat with c = 1 to colNum
-- put revDatabaseColumnNamed(curID, line c of colNames) & tab after tRec
put revDatabaseColumnNumbered(curID, c) & tab after tRec
end repeat
put tRec & cr after fld "Select"
-- revMoveToPreviousRecord curID
revMoveToNextRecord curID
if the result = false then exit repeat
end repeat
end if
delete last char of fld "Select"
revCloseCursor curID
end mouseUp
Select ID ` : H cREVGeneral revUniqueID 1030149305310 Edit Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put the hilitedLine of fld "Tables" into lineNum if lineNum is empty then answer error "Please select a table." exit mouseUp end if put line lineNum of fld "Tables" into tableName put the hilitedLine of fld "Select" into lineNum if lineNum is empty then answer error "Please select a record." exit mouseUp end if put line lineNum of fld "Select" into oldData replace tab with cr in oldData put fld "New headers" into theHeaders put the number of lines in theHeaders into headerCount put line 1 to headerCount of fld "New record" into newData repeat until the number of lines in newData = headerCount put cr after newData end repeat put "UPDATE " & tableName & " SET " into theSQL repeat for each line L in oldData if L is a number or L = "NULL" then put L & cr after fOldData else if L is not empty then put "'" & L & "'" & cr after fOldData else put cr after fOldData end repeat put fOldData into oldData repeat for each line L in newData if L is a number or L = "NULL" then put L & cr after fnewData else if L is not empty then put "'" & L & "'" & cr after fnewData else put "NULL" & cr after fnewData end repeat put fnewData into newData repeat with x = 1 to the number of lines in oldData if line x of oldData <> line x of newData then put line x of theHeaders & " = " & line x of newData & ", " after theUpdate end if if line x of oldData is not empty then put line x of theHeaders & " = " & line x of oldData & " and " after theSpecs end if end repeat delete char -2 to -1 of theUpdate delete char -5 to -1 of theSpecs put theUpdate & " WHERE (" & theSpecs & ");" after theSQL put theSQL into fld "SQL" send mouseUp to btn "Execute" send mouseUp to btn "Select" in 5 ticks end mouseUp t 2 cREVGeneral scriptChecksum mUśG bookmarks revUniqueID 1030153958940handlerList mouseUpscriptSelection char 634 to 633prevHandler mouseUptempScript scripton mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put the hilitedLine of fld "Tables" into lineNum
if lineNum is empty then
answer error "Please select a table."
exit mouseUp
end if
put line lineNum of fld "Tables" into tableName
put the hilitedLine of fld "Select" into lineNum
if lineNum is empty then
answer error "Please select a record."
exit mouseUp
end if
put line lineNum of fld "Select" into oldData
replace tab with cr in oldData
put fld "New headers" into theHeaders
put the number of lines in theHeaders into headerCount
put line 1 to headerCount of fld "New record" into newData
repeat until the number of lines in newData = headerCount
put cr after newData
end repeat
put "UPDATE " & tableName & " SET " into theSQL
repeat for each line L in oldData
if L is a number or L = "NULL" then put L & cr after fOldData
else if L is not empty then put "'" & L & "'" & cr after fOldData
else put cr after fOldData
end repeat
put fOldData into oldData
repeat for each line L in newData
if L is a number or L = "NULL" then put L & cr after fnewData
else if L is not empty then put "'" & L & "'" & cr after fnewData
else put "NULL" & cr after fnewData
end repeat
put fnewData into newData
repeat with x = 1 to the number of lines in oldData
if line x of oldData <> line x of newData then
put line x of theHeaders & " = " & line x of newData & ", " after theUpdate
end if
if line x of oldData is not empty then
put line x of theHeaders & " = " & line x of oldData & " and " after theSpecs
end if
end repeat
delete char -2 to -1 of theUpdate
delete char -5 to -1 of theSpecs
put theUpdate & " WHERE (" & theSpecs & ");" after theSQL
put theSQL into fld "SQL"
send mouseUp to btn "Execute"
send mouseUp to btn "Select" in 5 ticks
end mouseUp
Add Epon mouseUp put getConnectID() into dbID if dbID is empty then exit mouseUp put the hilitedLine of fld "Tables" into lineNum if lineNum is empty then answer error "Please select a table." exit mouseUp end if put line lineNum of fld "Tables" into tableName put "INSERT INTO " & tableName & " VALUES (" into theSQL put fld "New record" into newRec if newRec is empty then exit mouseUp put empty into formatRec repeat for each line L in newRec if L is a number or L = "NULL" then put L & ", " after formatRec else put "'" & L & "', " after formatRec end repeat delete char -2 to -1 of formatRec put formatRec & ");" after theSQL put theSQL into fld "SQL" send mouseUp to btn "Execute" send mouseUp to btn "Select" end mouseUp 8 2 Selection Description false cREVGeneral scriptChecksum ^RF bookmarks revUniqueID 1030153958940handlerList mouseUpscriptSelection char 325 to 324prevHandler mouseUptempScript scripton mouseUp
put getConnectID() into dbID
if dbID is empty then exit mouseUp
put the hilitedLine of fld "Tables" into lineNum
if lineNum is empty then
answer error "Please select a table."
exit mouseUp
end if
put line lineNum of fld "Tables" into tableName
put "INSERT INTO " & tableName & " VALUES (" into theSQL
put fld "New record" into newRec
if newRec is empty then exit mouseUp
put empty into formatRec
repeat for each line L in newRec
if L is a number or L = "NULL" then put L & ", " after formatRec
else put "'" & L & "', " after formatRec
end repeat
delete char -2 to -1 of formatRec
put formatRec & ");" after theSQL
put theSQL into fld "SQL"
send mouseUp to btn "Execute"
send mouseUp to btn "Select"
end mouseUp
New headers * R cREVGeneral revUniqueID 1030154290833 Select headers g d cREVGeneral revUniqueID 1030154866384 Counter ` S : cREVGeneral bookmarks revUniqueID 1030157798094handlerList scriptSelection char 1 to 0prevHandler tempScript script Add table Ep ^on mouseUp go to stack "Table" set the label of btn "Do" to "Make the table" end mouseUp V cREVGeneral scriptChecksum WDC$mr8 bookmarks revUniqueID 1030320866598handlerList mouseUpscriptSelection char 93 to 92prevHandler mouseUptempScript scripton mouseUp
go to stack "Table"
set the label of btn "Do" to "Make the table"
end mouseUp
New Field 1 d cREVGeneral revUniqueID 1030148627680 User name: db user i` f cREVGeneral scriptChecksum ُ B~revUniqueID 1030147405748 bookmarks handlerList tempScript prevHandler mouseUpscriptSelection char 1 to 0script db address i` f H cREVGeneral scriptChecksum ُ B~ bookmarks revUniqueID 1030147405748handlerList scriptSelection char 1 to 0prevHandler mouseUptempScript script New Field 1 H d cREVGeneral revUniqueID 1030148627680 Address: New Field 3 ` X<