Arc Forumnew | comments | leaders | submitlogin
using MySQL with arc?
2 points by thaddeus 5501 days ago | 10 comments
I've historically been using oracle. A year ago I only needed a few database elements to use in an arc program and so I had gotten by on using system calls to sql scripts that in turn generate flat files which I would then parse and load. I know, I know .... ugly, but that was a year ago when I first started to code. I still don't have the need, but I have decided to start learning MySQL and thought it would be a great idea to learn it using arc.

Anyway... I've noticed about a half dozen or so post on this already, but they date back quite a while prior to v3.1 so I am going to ask again...

Has anyone had any experience using arc to open and manage a connection to mysql? Does anyone have any feedback or guidance prior to me taking a look?

I have noticed there's a mysql library on anarki-v2-master, which at first glance looks great (was written for arc v.2).

http://github.com/nex3/arc/raw/arc2.master/lib/mysql-ffi.arc

Has anyone been using this library?

Or does anyone have general opinions / thoughts on going down this road?

I guess there are a few other options such as generating php scripts, but that puts me back close to my original system calls.

I think MySQL is a good db choice. Are there any opinions on which dbs? I have heard there are dbs that don't require 'types' where everything is a string... could this be a good fit for arc?

Thanks, T.



2 points by jmatt 5493 days ago | link

In the past I have gotten a sqlite C binding working through an old alpha version of the ffi. It was never completely stable and was failing in the ffi. But it was doable. I had limited time and couldn't hunt down where it was failing in the ffi. I didn't have any requirements to use the FFI and was just exploring the possibility. So I moved back to SQLite using JGC's TCP server [1]. Which was a great solution! It wasn't especially portable between mac and linux (ie deploying it to my web server). But it was fast to set up and robust on the mac.

Similarly I worked on MySQL bindings but they were never robust enough to use especially in comparison to the JGC solution. This was a few versions ago before the ffi was flushed out. Maybe a similar TCP server using MySQL would make sense. I know it worked really well for me. I had problems making it portable (between Ubuntu / FreeBSD). But after those problems were worked out it was stable.

Good luck. I'm interested in what ends up working for you.

[1] http://www.jgc.org/blog/2008/02/interface-to-sqlite-database...

-----

4 points by thaddeus 5492 days ago | link

Thanks for the reply.

I ended up using dbslayer to interface with mysql. And along with aw's json combinator + stefano's? http-get/utils - it works brilliantly!

http://code.nytimes.com/projects/dbslayer

http://awwx.ws/combinator/

http://github.com/nex3/arc/tree/arc2.master/lib/http-get/

One note: I needed to change the dbslayer source code, prior to making the install, in order to eliminate the spaces that aw's combinator would choke on. It was a trivial change though...

[EDIT: Correction I was using an older version of aw's combinator - the new version handles spaces]

T.

-----

1 point by aw 5492 days ago | link

That's cool. It's a neat idea that by default (if there isn't an explicit reason why you have to do something else), all interfaces can be HTTP, and as a bonus use JSON as your data interchange format...

-----

1 point by thaddeus 5492 days ago | link

Exactly. The concept is great. Even now when I am starting to learn haskell, the first thing I am doing checking out haskells' JSON parser to communicate via HTTP. Conceptually I can keep doing this and communicate easily across any language. And since SQL to URL is so basic I can re-use/apply dbslayer to any language too.

-----

1 point by aw 5491 days ago | link

Aha, I knew I'd seen some post that talked about this, and I found it: http://timothyfitz.wordpress.com/2009/02/12/why-http/

-----

1 point by thaddeus 5501 days ago | link

ok, It took me about an hour to install & learn MySQL without any hickups. :)

I did get stuck on the arc mysql library. I have to admit I'm not loading anarki I am just seeing if I can load ffi.scm into arc3.1.

in ffi.scm there's:

  (require #%foreign)
which I'm guessing is the reason I get:

   #%foreign: bad module path in: #%foreign
   === context ===
   standard-module-name-resolver
Anyone understand the syntax '(require #%foreign)'? Is this a scheme thing or an anarki thing?

Thanks, T.

-----

1 point by akkartik 5501 days ago | link

After using arc for 5 months I'm fully given over to the dark side - I just use hash tables that persist to flat files. I've never felt the need for a schema or complex query.

-----

2 points by thaddeus 5501 days ago | link

Which is what I've been doing too and is fine if you own & control the data, but what happens when the data you want to consume exist in a source where the owner uses an Oracle or MySQL db?

-----

1 point by akkartik 5501 days ago | link

Yeah, I didn't mean to imply arc doesn't need mysql bindings or anything like that. I think I was just giving thanks :)

-----

1 point by thaddeus 5501 days ago | link

I agree. The fact that I've been able to develop fairly complex applications in arc for so long without requiring a db is awesome.

-----