Sunday 22 September 2013

Postgresql in Dart

So I was curious, about how difficult it was talking to a PostgreSQL server from Dart. so I wrote some code to find out. Before we get to the Dart code though, we’re going to need a database and some sample data.


Next up is the actual Dart code, which is pretty dang nice, if I may say so myself.  :-)

We start out by importing the “postgresql” pub package, then we connect to the database, insert a new record, and finally we display the data from the database.

I found it surprisingly easy to get going. It have this great thing where you can just type the name of column you want to access, and you get the data out as the right data type.

One thing to note is that it only works as a command line program, not from the browser, which shouldn't be that much of a surprise to anybody.

No comments:

Post a Comment