Arc Forumnew | comments | leaders | submitlogin
Arc cgi script that connects to postgresql?
3 points by qbit 5734 days ago | 6 comments
I just read the arc tutorial and it looks like a nice language. I'd like to start experimenting with it and was wondering if it's possible to write a cgi script in arc that connects to a postgresql database? Are there any references or tutorials showing how to do this?


2 points by shader 5732 days ago | link

There was one attempt a while ago to get mysql to work with arc.

As for using arc as an cgi script, it has a rather slow load time. If you are loading for every request it will be quite slow. That's one reason that arc includes it's own web server.

One common way of using arc is to run it behind an apache server with mod_proxy.

-----

1 point by justgord 5726 days ago | link

As an interim hack to get to postgres data, I'm currently using system to call the external psql command - less than ideal :[

<pre> (def sqltxt (sql) (system (string "psql -c " "\"" sql "\"" ))) </pre>

[ I guess opening a socket to the db server and parsing the resultset wouldn't be much harder if its text mode - could probably use the perl or ruby pglib as a guide, and port from that... ]

-----

2 points by shader 5726 days ago | link

Hmm. I would think that you wouldn't want to open a new psql connection every time you want to look something up.

How about running the system command in a thread, which redirects psql's stdin and stdout to named pipes so that another arc thread could read from it using file read commands? That would give you more persistence, so you wouldn't have to keep loading psql.

Also, have a look at lib/mysql-ffi.arc in anarki; supposedly it has a ffi for mysql, though I haven't really looked at it much myself.

-----

1 point by justgord 5726 days ago | link

yeah or theres the mz: extension to access one of mzschemes pgsql libs...

Sure its ugly/slow.. but allows me to prototype in the meantime.

Thanks for the mysql ref, I'll take a look.

-----

2 points by absz 5726 days ago | link

I can't help you with the SQL, but I can give you a formatting tip: to get

  code formatted like this,
surround your code block with a blank line on each side and indent each line of code by at least two spaces.

-----

2 points by justgord 5726 days ago | link

  (prn "thanks absz")

-----