Reading data from an Oracle / MySql database with D3js

1,731 views
Skip to first unread message

Robert R. Raiz

unread,
May 19, 2014, 5:07:31 AM5/19/14
to d3...@googlegroups.com
Hello all,

I was wondering if this can be accomplished. I bet it can, but which would be the recommended way?
If anyone can help me out with an advice, or even an example, I would appreciate it.

Basically, I am trying to create a chart with some values, xAxis for year, yAxis for number of population.
I managed to do this in a nice way using an array of Objects inside the script or a tsv external file, but I want to do it from a database.

Thank you all for your time,

Andy Thornton

unread,
May 19, 2014, 7:22:55 AM5/19/14
to d3...@googlegroups.com
It is certainly possible, but it's more a backed question than D3 question. If you can get your backend to serve up the data as json or csv, you simply use d3.json or d3.csv to request the data. What are you working with server-side? 
--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert R. Raiz

unread,
May 19, 2014, 9:47:25 AM5/19/14
to d3...@googlegroups.com
Hello Andrew,
Thanks for the quick reply!
Perl language would be my answer;
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+unsubscribe@googlegroups.com.

Nick Guenther

unread,
May 20, 2014, 3:39:05 PM5/20/14
to d3...@googlegroups.com

I do not know about perl, but in python I am using
http://dataset.readthedocs.org/en/latest/api.html#dataset.freeze

Dataset also has a "freezefile" script which you could use without
having to program python. Perhaps you can rig up freezefile under a
cron job to dump the csv to a webserver directory?

If you are a bit more enthusiastic, look into getting MySQL triggers to
write out a "/tmp/csv_is_dirty", and write a cgi that handles your
d3.csv which first uses that file to know if it needs to redump the db.

If you are looking for something more responsive (like, AJAX messages
sending everytime a row is added to the db)... well, I'm looking into
that myself at the moment.

I hope this gives you ideas! I am struggling with this very issue.


--
-Nick Guenther
4A Stats/CS
University of Waterloo

matthew lange

unread,
May 20, 2014, 4:10:14 PM5/20/14
to d3...@googlegroups.com
Wow Nick, this looks kind of cool...and python, yum! Might I ask, are you using this within a specific python web development framework?


--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.

Robert R. Raiz

unread,
May 21, 2014, 9:33:48 AM5/21/14
to d3...@googlegroups.com, ngue...@uwaterloo.ca
Well, I actually know Python way better than Perl so this might work.
Regardless of the server-side version I am currently using, I just have to find a way to make a presentation on how d3js works if one needs to "take" its data from a databse.
I can play around with your advice as I needed a starting point for this.

Andrew W

unread,
May 25, 2014, 6:17:34 AM5/25/14
to d3...@googlegroups.com
Have a look at the web2py framework. I use it to extract from databases and present data in a d3 appropriate format. It's python based too.
Web2py.com

Jonas Langvad

unread,
May 28, 2014, 12:54:55 AM5/28/14
to d3...@googlegroups.com
Hi Robert,

I recently figured out how to get data from mysql using PHP. I know you mentioned python/perl so it may not be 100% relevant. However, take a look at my example if you think it might help: https://groups.google.com/forum/#!topic/d3-js/CW4xR9-UVUI

Keep in mind that I'm relatively new to d3 and programming so the code could probably be improved upon.

Robert R. Raiz

unread,
May 28, 2014, 9:09:39 AM5/28/14
to d3...@googlegroups.com
Joans,

I am in the same spot as you are so many thanks for the feedback. I will look into it.

Best,
Reply all
Reply to author
Forward
0 new messages