Code: Select all
revdberr,Lost connection to MySQL server during queryModerators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
revdberr,Lost connection to MySQL server during query

Wait a minute, databases don't work good this way.Not a lot of thought wrote:I've been struggling with lost connections on long queries going back to a MySQL database. The database connection is fine (from the database side); internet connection is good, but for some reason Livecode only lets the DB query run for about a minute before it records
What if I need it to run for several minutes or half an hour or something? I've tried doing smaller requests, but then it seems that I lose connection after the databaseConnect function is run too many times. If the databaseConnect isn't run in every iteration of a loop then it still loses connection. So, I'm at a loss on how to sustain longer server connections.Code: Select all
revdberr,Lost connection to MySQL server during query
Code: Select all
BEGIN TRANSACTION;
first query;
second query;
...
last query;
COMMIT;Code: Select all
      put "START TRANSACTION;SELECT Company_ID FROM Company_Data GROUP BY Company_ID ORDER BY Company_ID ASC;COMMIT;" into LoadSQL
      revExecuteSQL gDatabaseID, LoadSQLCode: Select all
      put "BEGIN TRANSACTION;SELECT Company_ID FROM Company_Data GROUP BY Company_ID ORDER BY Company_ID ASC;COMMIT;" into LoadSQL
      revExecuteSQL gDatabaseID, LoadSQLCode: Select all
on mouseUp
   
   put revOpenDatabase("mysql","XX.XX.XX.XX",YourdbName,YourdbUser,YourdbPass,,,0,false) into dbID
   
   ------- note the 0 = documentation = " (MySQL Only)  A number specifying the database read/write timeout in whole seconds.  Defaults to 20 seconds if empty or not a positive integer. If 0, the connection never times out."
   
   if dbID is not a number then
      answer error dbID
      exit to top
   end if
   
   put "SELECT Company_ID FROM Company_Data GROUP BY Company_ID LIMIT 200" into dbSQL
   
   put  revDataFromQuery(, , dbID, dbSQL) into tTheData
   
   revCloseDatabase dbID
   if tTheData begins with "revdberr" then
      answer error tTheData 
      exit to top
   end if
   
   answer the number of lines of TheData
   
   put TheData
   
end mouseUPIn your case just try this:Not a lot of thought wrote: ...
I really only want to do one thing at the moment, and that is just return a distinct list of the names of the companies in the table, in order to do a loop later to go through and run a query against each name for certain information.
...
What am I missing here?
Code: Select all
put  revOpenDatabase("mysql", "www.example.com", "myDB", myUsr, myPass, false , , 600, true) into ConnectionID
put "SELECT DISTINCT Company_ID FROM Company_Data  ORDER BY Company_ID ASC;" into tSQL
put revDataFromQuery( , return, ConnectionID, tSQL) into myVar