When will be possible for using sql databases from Dart

1,324 views
Skip to first unread message

altun

unread,
Apr 17, 2012, 5:55:44 AM4/17/12
to General Dart Discussion
When will be possible for using sql databases from Dart. Is there any
work (or plan) related to this subject in dart team.

There is a related thread about this. http://goo.gl/QHRLj

Thanks in advance

Altun

Mads Ager

unread,
Apr 17, 2012, 6:25:35 AM4/17/12
to altun, General Dart Discussion
I know that there is a third-party library for using mongodb in
server-side dart code. I'll let Vadim comment on how stable that is.

https://bitbucket.org/vadimtsushko/mongo-dart

It would be possible to write a similar library at this point for sql
databases that provide a socket API. Additionally, we are providing
native-extension support that will allow you to wrap native libraries
in nice dart APIs. We will be posting an article on how to do that in
the near future. That will provide an additional way of providing
access to databases using their C APIs.

Cheers, -- Mads

James Ots

unread,
Apr 17, 2012, 11:14:01 AM4/17/12
to General Dart Discussion
I'm working on a MySQL connector for Dart at the moment. It'll be here
when it's ready: https://github.com/jamesots/sqljocky

It currently works reasonably well, but there are a few rough edges I
want to smooth out before I let anyone else see it, which might be
tonight, but will probably be later this week. Warning: At that point
it will still be in a very alpha state, as it needs a lot of testing
on different versions of MySQL, and there are some commands which are
still unimplemented. I'll appreciate other people using it, reporting
issues and contributing code though.

James Ots
> > There is a related thread about this.http://goo.gl/QHRLj
>
> > Thanks in advance
>
> > Altun

Seth Ladd

unread,
Apr 17, 2012, 11:25:49 AM4/17/12
to James Ots, General Dart Discussion
Thanks James, please ping the list again when you push your code. Looking forward to it!

altun

unread,
Apr 17, 2012, 11:57:45 AM4/17/12
to General Dart Discussion
Thanks James. We'll be waiting for you.

Michael Chean

unread,
Apr 17, 2012, 12:06:48 PM4/17/12
to mi...@dartlang.org
Is anyone looking at a more generic DAL approach?  

Vadim Tsushko

unread,
Apr 18, 2012, 3:13:58 AM4/18/12
to General Dart Discussion
>>I know that there is a third-party library for using mongodb in
>>server-side dart code. I'll let Vadim comment on how stable that is.

Well, it is educational/hobbying project with limited commited
resources.
I would recommend to try it in similar educational projects.
OTOH it is an opportunity to try something of no classical sql type.
I've now thinking that NoSql persistency may successfully be used in
many types of web applications instead of SQL - ORM pair or Active
Records.

James Ots

unread,
Apr 19, 2012, 7:11:11 PM4/19/12
to mi...@dartlang.org
I have pushed my code to github. As I said, it's still early stages of
development, so expect large changes and reorganizations of the
codebase. There's an incomplete To Do list in the readme file. There's
quite a lot of stuff I need to fix or refactor, and I definitely need
to write more tests.

I initially wrote a synchronous transport as well, but since I think I
was misusing the sockets API it didn't work on Windows, and
continually looping to read data seemed like a bad idea, so I removed
it. It takes some getting used to using chained Futures when accessing
a database, but, except for the stacktrace problem, it isn't too bad
really.

James Ots

Seth Ladd

unread,
Apr 19, 2012, 7:24:40 PM4/19/12
to James Ots, mi...@dartlang.org
Thanks James! I'll help spread the word.

Mads Ager

unread,
Apr 20, 2012, 3:50:47 AM4/20/12
to James Ots, mi...@dartlang.org
Very cool! Thanks for doing this James. :)

I quickly browsed the code and it is looking good. On a quick reading,
the one thing I noticed was that the writing to sockets is a bit
optimistic:

https://github.com/jamesots/sqljocky/blob/master/lib/buffer.dart#L57
https://github.com/jamesots/sqljocky/blob/master/lib/transport/transport_impl.dart#L68

This will most likely break at some point when you cannot write all
the data in one write operation. Maybe add 'assert(written ==
expected)' after each use so you catch it when it breaks? There are a
couple of ways of dealing with this: either use the socket output
stream which will deal with this for you or buffer up data yourself
and hook up an onWrite handler that writes more data when the socket
is ready to deal with more again. The output stream is probably the
simplest.

Thanks again for doing this. It is very nice to see projects like this!

Cheers, -- Mads

James Ots

unread,
Apr 20, 2012, 3:57:07 AM4/20/12
to Mads Ager, mi...@dartlang.org
The socket reading and writing code was the first part I wrote, and at
the time I just wanted to hack together something just to see if I
could even log into a mysql server from dart. I meant to do a major
refactor on that, but had forgotten. Thanks for reminding me.
Actually, there's a lot of code still in there which is rather nasty,
but nothing that can't be refactored into oblivion. (The evil
synchronous socket code has already been sent to Coventry.)

James

Reply all
Reply to author
Forward
0 new messages