Squirrel SQL Resonnect Session - squirrel-sql

In my Squirrel SQL, I've got a few session tabs, each with a number of open tabs for queries I have run in the past and corresponding query results.
That is very handy should I want to "re-live the experience of firing a query" or quickly modify a query if I need to tweak that.
Sadly, after a period of inactivity (I have learnt how to increase session timeout of Squirrel SQL Client, so that is not part of the question), I no longer can fire any queries in that tab, as shown in the picture below
Is there a way to re-connect expired session to a DB connection again or any other way to fire the queries, other than copy and paste them from the expired session tab to a newly connected session?

You can reconnect the session using Session → Reconnect or Ctrl-Alt-T.

Related

Trigger script when SQL Data changes

I'm trying to make a live react control panel, so when you push a button on the web control panel the data (true or false) goes to the SQL database (phpmyadmin) and the when the data changes te SQL database should trigger a script on the raspberry pi that will turn the light on.
I know how to write data to the SQL database and how to control a lamp with a raspberry pi but I dont know how to trigger or execute something when data in the SQL database gets updated.
It needs to live, like react in max 20 ms or something. Can anyone help me with this?
The SQL Database runs on Ubuntu and is phpmyadmin based.
Greets,
Jules
Schematic:
DataUpdateGraphical
It's not a good idea to use a trigger in MySQL to activate any external process. The reason is that the trigger fires when the INSERT/UPDATE/DELETE executes, not when the transaction commits. So if the external process receives the event, it may immediately go query the database to get other details about that data change, and find it cannot see the uncommitted data.
Instead, I recommend whatever app is writing to the database should be responsible for creating the notification. Only then can the app wait until after the transaction is confirmed to be committed.
So your PHP code that handles the button press would insert/update some data the database, and check that the SQL completed without errors (always check the result of executing an SQL statement) and the transaction committed.
Then the same PHP code subsequently calls your script, or posts an even to a message queue that the script is waiting for, or something like that.
Just don't use the MySQL as a poor man's message queue! It's not the right tool for that.
The same advice applies to any other action you want to do external to the database. Like sending an email, writing a file, making an http API call, etc.
Don't do it in an SQL trigger, because external actions don't obey transaction isolation. The trigger or one of the cascading data updates could get rolled back, but the effect of an external action cannot be rolled back.
MySQL doesn't have a way to deliver an event to external software from within a trigger. That's what you need to have your database push events to your app.
(Actually, it's possible to install a user-defined function that sends an industry-standard stomp messsage to a message queue system like rabbitmq . But you will have to control the entire server, AND your database administrator, to get that installed.)
The alternative: run a query every so often to retrieve changed information, and push it to your app. That's a nasty alternative: polling is a pain in the xxx neck.
Can you get your server app to detect changes as it UPDATEs the database? It'll take some programming and testing, but it's a good solution to your problem.
You could use redis instead of / in addition to MySql. redis sends events to web servers whenever values change, which is close to perfect for what you want to do. https://redis.io/topics/notifications

Spotfire connection with MySql

I have been trying to use MySql data with Spotfire, Had a connection established and managed to make a working dxp file. Tried to do the same with a second table and it threw this error
The following error message "Streaming result set com.mysql.jdbc.RowDataDynamic#XXXXXX is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries" comes from MySQL.
afterwards I opened my already working dxp file and the error popped again. It seems I somehow have a connection still open and active but spotfire is suppose to manage the connection as far as I know at least
After looking this up online some people say it's a bug, others say I need to close the connection, but I can't find a solution. Please help
Edit: changing the minimum connections number (which probably closes the open connections) makes ot possible for the dxp to run once but then it fails the second time (after closing and opening)

Phpmyadmin blocks when executing a large query

I am using phpmyadmin for my MySQL administration. When I'm doing an expensive query, which takes several minutes, phpmyadmin seems to block all other activities going on in other tabs. I can still use the mysql console for queries, but I can't use phpmyadmin anymore in any tab, it loads and finish only when the big query in the other tab is finished. Can I change this somehow?
That's because of the way php handles sessions. One session can only be used by one script at a time. In one browser all tabs use the same session so they have to wait for the task to complete.
If you log in to phpMyAdmin in another browser, you have create a new session and can do things in parallel. (Because each browser has its own cookie store)
Phpmyadmin is designed to be a single session through the webserver into the database. If you need to be supportive of more sessions, then you must use a client (console, sqlyog, toad) to be able to use multiple threads on the database, or use another browser so it has another session handler at the same time.
As this still seems to be quite popular, let me add up to date answer.
Since phpMyAdmin 4.5.0 the session is not locked while executing SQL query (and other possibly long lasting operations). See https://github.com/phpmyadmin/phpmyadmin/issues/5699 for more information.

"Lost connection to MySQL server during query" kills Windows Service

I have developed a windows service using Delphi 2007. It connects to a remote MySql database via the internet using TAdoConnection and TAdoQuery. I have retained the default value of 30 seconds for CommandTimeout property. I also create the connection/query objects on each new query and free them when done (i.e. I don't create the database connection at startup and keep it open).
Every once in a while the service stops and the event viewer shows "Lost connection to MySQL server during query". I have everything wrapped in exceptions. My suspicion is that there is a drop in the network while the query is executing.
Anyone have any resolution/ideas?
What triggers windows to shutdown the service?
Also, I have the service "Recovery" set to restart the service but this never happens.
My next step will be to start logging when each query starts and compare this to the date/time of the shutdown. Because as of now I don't know how log this is.
This is may be not a direct answer, but I had same problem few days ago, and I have the mysql on local server, and I connect using Mydac components.
After many tries, I found the problem came from one table that has BLOB fields, I tried to query on the table like
select * from table
And I got this problem after the query fetch around 1600 rows, after few inspection I found the problem came from few records and seems they corrupted. so when I do query like
Select * from my table where id not
between 1599 and 1650
I had this problem, if I removed Not from they query which fetch only 51 records I got the error, which means there's some records are corrupted, also I did mysqlcheck but it didn't fix the problem, and I tried some other check tools and I got same result, I didn't tried to delete these records, because I need why this problem happen, but I got busy with other things so I left the server for a while.
BTW, I used MySql Query browser for trying to do the queries, because other tools will give me the errors without showing how many records fetched before mysql instance terminated unexpectedly.

MS Access caching of reports / query results

Is it possible to cache a query or report the first time it is run? It seems that opening a report will re-query the datasource. For certain queries, the data source does not change frequently enough that I'd be worried about a cache being out of date (users are notified when the database changes), and it would be much easier for the users to be able to open the report instantly rather than having to wait several minutes every time they want to see the data (though I realize if they close the file the caches will be lost - that's OK).
Data comes from an ODBC connection to Oracle, using Access 2003.
Most server databases cache ad hoc SQL statements. That is, if you run the report, Oracle should cache the result, and if it sees the SQL statement come across the wire again, deliver the result from the cache instead of retrieving it all from scratch. I know that SQL Server does this and I assume any enterprise-level database will do the same. Along with the caching, of course, is some form of checking to insure that the cached data is still up-to-date. I don't know what level of control the DBA has over how this works, but you might look into implementing this server-side. A temp table might also be a solution.
Could you maybe keep the report open the entire time the database is open? Open it hidden when the database is opened.
DoCmd.OpenReport "YourReport", acViewPreview,,,acHidden
Then never close it while the database is open.
Alternatively, since you can deal with cache staleness, perhaps you could store the report's data in a local table for faster access. Since the users are aware of when new data is available, give them a command button which empties the local table and puts the latest Oracle data back in.