Arc Forumnew | comments | leaders | submitlogin
How can I connect to MySQL with Arc?
3 points by lark 4435 days ago | 21 comments
Can someone point me to a library that allows using Arc to connect to MySQL or PostgreSQL?

A search reveals threads on this forum on ffi, w/ffi and w/inline, but these threads do not always point to a URL that provides this code.



1 point by akkartik 4435 days ago | link

The code they're referring to is this, I think:

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

It's in a branch for the old Arc 2, so it probably won't work with Arc 3.1. It should provide a starting point, though; let us know if you get it working, and feel free to push it to http://github.com/nex3/arc/tree/master.

-----

1 point by lark 4435 days ago | link

It doesn't work.

Trying to load this file fails:

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> (load "mysql-ffi.arc")
  arc> Error: "reference to undefined identifier: _w/inline"

To be more clear, the complete code that makes MySQL work is nowhere to be found.

Before I posted this question, I went through these URLs and tried to put together their fragments with various errors.

-----

1 point by akkartik 4435 days ago | link

Yeah I'm not surprised it isn't working. We don't use a database with our arc programs, we just use flat files like HN does.

-----

1 point by lark 4435 days ago | link

Does anyone know where I can get the w/inline source?

Does anyone have the tiniest example of a working FFI?

-----

1 point by akkartik 4435 days ago | link

w/inline and the rest of the FFI is right there if you browse on github: http://github.com/nex3/arc/blob/arc2.master/ffi.arc

Do you need help downloading that (extremely old) version of arc from github?

-----

1 point by lark 4435 days ago | link

The following may be premature: based on what I managed to assemble so far, I now get:

  ffi.scm:4:6: let: bad syntax (not an identifier) at: (quote ffi-lib) in: (let ((nm (ac-global-name (quote (quote ffi-lib)))) ((quote ffi-lib) ffi-lib)) (namespace-set-variable-value! nm (quote ffi-lib)) (quote ffi-lib))

-----

1 point by akkartik 4435 days ago | link

Can you tell me what steps you followed to install arc?

-----

1 point by lark 4435 days ago | link

The usual steps from http://arclanguage.org/install

This is using Arc 3.1, not Arc 3, and with an mzScheme 3.7.2 built from source. Other Arc apps I've written work, and news.arc, blog.arc etc. work.

-----

1 point by kinleyd 4435 days ago | link

Why not use more current versions of MzScheme - see https://sites.google.com/site/arclanguagewiki/install-arc

-----

1 point by lark 4434 days ago | link

I was not aware of the instructions being out of date.

Still, the error I'm facing does not seem related to mzScheme.

-----

2 points by akkartik 4434 days ago | link

Here's what I've tried so far:

a) Install v372 from http://download.plt-scheme.org/v372.html on a debian linux laptop.

b) Run the shell script, install it to the directory containing the arc2.master branch.

c) Run:

  plt/bin/mzscheme --no-init-file --load as.scm
It seems to come up without errors and ffi.arc seems to be loading up.

(When you report errors it's usually much faster to tell people how to reproduce your error in this step by step manner. Then they can usually immediately look at the instructions and tell you what you're doing wrong without a lengthy back-and-forth.)

-----

1 point by lark 4434 days ago | link

Here's what I've tried and the outcome:

http://arclanguage.org/item?id=15723

-----

1 point by akkartik 4434 days ago | link

Can you try the steps I outlined and confirm that it works for you? Perhaps something's messed up about the version you're on. Once you have a working version we can go in and poke at the differences to see where the problem might be.

-----

1 point by lark 4434 days ago | link

I tried the steps and Arc comes up. So ffi.scm must be working.

-----

1 point by akkartik 4434 days ago | link

Great. Can you share a copy of the repo that isn't working? Maybe on github or something?

-----

1 point by lark 4433 days ago | link

I can't share a copy of the repo, but I'm going about introducing FFI the opposite way: pick Arc 3.1 and add any files that are needed to get just FFI and mysql-ffi.

That's the approach that leads into trouble.

-----

1 point by akkartik 4432 days ago | link

That's a good approach. Keep at it, I'm sure you'll figure it out.

One way to get help with it: describe simple step-by-step changes to the repo that cause errors. Download arc 3.1, add this file from here, type this in at the repl, etc. Don't forget the actual text of the error you see as well.

-----

1 point by lark 4435 days ago | link

Well, after extracting the code from that Git branch, I don't see anything related to "(quote ffi-lib)" that can be fixed/added/changed.

In short, FFI doesn't work.

-----

1 point by lark 4435 days ago | link

I do.

How can I download what that URL shows without lots of mouse-clicks?

The following brings down something that's different than what the URL shows:

  git clone https://github.com/nex3/arc.git

-----

2 points by akkartik 4435 days ago | link

Once you've cloned it:

  git checkout arc2.master

-----

1 point by lark 4435 days ago | link

Thanks.

That version of Arc doesn't work.

  $ ./arc.sh 
  Compiling arc.arc...
  call-with-input-file: cannot open input file: "/home/dark/nex3/arc/bell-style" (No such file or directory; errno=2)
  >

-----