Pregunta

So I kinda want to do so interaction with my MySQL Server using Dart. I looked up how people did this and I got to get sqljocky. Now I import the sqljocky in my main file, I get the error: The built-in library 'dart:io' is not available on Dartium. Now what is going wrong around here and why did Google make dart:io when it's not available for Dartium?

Thanks in advance!

¿Fue útil?

Solución

The dart:io library is available for server side processes similar to Node.js. It allows developers to have one language on both the client and the server. It provides capabilities such as creating native sockets, native file i/o etc, that cannot be accomplished client side (in any language) due to the sandboxing restrictions.

SQLJockey uses the ability to create native sockets to connect to a MySQL server. Its not something that can be done client side (or at least not easily at all) and even if it could, it should not be done as once code is client side it's always susceptible to modification by an end user (I can modify the javascript in my browser on any page I hit to behave differently). Server-side you can sanitize commands sent to a database and not worry that someone else would be able to change your sanitization rules. And of course that's not to mention just having username and password for your MySQL in your client-side code for anyone to access and the fact that your MySQL connection would need to accept logins form everywhere not just 'localhost' or a specific server/domain would leave you far too susceptible.

So the dart:io library is to be run server-side like a Ruby (on Rails, or Sinatra, etc) script, or like PHP or like Node.js. It's not designed to run client-side as it provides functionality which cannot be implemented in a browser for security reasons (this security is built into the browser not just the languages).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top