You need to go through the server. Giving the client-side code direct access to the database would be a massive security hole, even if you could do it.
What you should do is implement a small server-side script perhaps in PHP or Perl or Python or C#, which outputs just the data you want from the query and use AJAX to process the response.
You need to use a server side language. Otherwise that would be a huge security hole. Anyone could access this database and send arbitrary SQL queries to it.
In theory, it should be possible using the newer features like web sockets, etc. But you shouldn't do it, considering you'd have to make your credentials public. Create a server side wrapper/negotiator script in whatever available language you'd like to use and call that one. You can as well use it to validate inputs (e.g. filter too absurd highscores or impossible values; depending on what you're doing).
©2020 All rights reserved.