1

G'Day,

Is it possible to query mySQL directly from within jQuery without having to use PHP/Python/Ruby etc.?

TheEdge
  • 9,291
  • 15
  • 67
  • 135
  • possible duplicate of [Directly accessing server database via Ajax (without PHP or some other intermediate)](http://stackoverflow.com/questions/2256310/directly-accessing-server-database-via-ajax-without-php-or-some-other-intermedia) – Haim Evgi Feb 24 '11 at 08:24
  • There is a very good reason that this is (next to) impossible to achieve. If users can directly acces your database, all your data is available to everybody! It's like having a direct shell into your mysql database! – gnur Feb 24 '11 at 08:30
  • I have a very specific need. The database and all clients are on a closed network, so while your concern about security is a valid one it is something I am able to exclude. – TheEdge Feb 25 '11 at 08:08

3 Answers3

2

You can't do it with MySQL because it uses a binary protocol that the browser doesn't speak. You can do it with CouchDB, though, which uses HTTP and JSON so it's perfect for this kind of thing.

Zed
  • 3,387
  • 19
  • 14
0

no, jQuery is on client side and it isn't able to access directly to the database

Xavinou
  • 802
  • 1
  • 6
  • 18
  • So there is no way to open a TCP socket from JQuery? And there is no JavaScript library to access MySQL? – TheEdge Feb 25 '11 at 08:14
0

No you can not do it. Because all jquery code runs on client. You can use jquery ajax methods to call php or another webservices. Simply jquery or another javascript library can not do it.

AEMLoviji
  • 3,217
  • 9
  • 37
  • 61