dart-drivers / mysql

MySQL Connector for Dart
Other
98 stars 38 forks source link

How to test on connection? #55

Closed thearabbit closed 9 years ago

thearabbit commented 9 years ago

I am newbie for Dart and SqlJocky. I try like this:

<body>
  <h1>MySQL</h1>

  <div class="widgets">
    <div>
      <button id="testButton">Test</button>
    </div>
  </div>
  <script type="application/dart" src="piratebadge.dart"></script>
  <script src="packages/browser/dart.js"></script>
</body>
import 'dart:html';
import 'package:sqljocky/sqljocky.dart';

ButtonElement testButton;

void main() {
  testButton = querySelector('#testButton');
  testButton.onClick.listen(testMysql);
}

void testMysql(Event e) {
  var pool = new ConnectionPool(host: '127.0.0.1', port: 3306, user: 'root', password: '123456', db: 'mydb', max: 5);

  pool.query('select name, email from users').then((results) {
    results.forEach((row) {
      print('Name: ${row.name}, email: ${row.email}');
    });
  });

}

it show error: Uncaught Unsupported operation: RawSocket constructor on brower console.

jamesots commented 9 years ago

SQLjocky will only work in the command-line VM, not in a browser.

thearabbit commented 9 years ago

so, could i get the data from db and view it on browser like alert()?