Connecting to an External SQL database using erlang

Bob <>
Tue Dec 5 15:35:43 CET 2000


> Is there any existing code written for erlang, which will let you
> connect to an external sql database?
> 

Aloha Adrian,

Attached is a module for MySQL that I use with httpd.  There are all sorts of things 'wrong' and unfinished with it.  But it works
pretty well.

It's also lacking in documentation, so feel free to ask.  Below, is the typical call that I used to query.

Hope this helps.
bob

P.S.  Thanks to all for their contributations to the OO metaphor thread over the past week or two.  Very educational.


%always returns colcount,row count,cols,rows
%
sql_fetch(Info,Sql)->
	case mysql:fetch(Info#mod.dbPid,"Stocks",Sql) of
		{records,ColCount,RowCount,Cols,Rows}->{ColCount,RowCount,Cols,Rows};
		{timeout,_} -> 
				ioDebug(sqlTimeout),
				ioDebug(list_to_atom(Sql)),
				{0,0,[""],["timeout"]};
		{error,_} -> 
				ioDebug(sqlError),
				ioDebug(list_to_atom(Sql)),
				{0,0,[""],["db error"]};
		{ok} -> {0,0,[""],["ok"]};
		_ ->	
				ioDebug(sqlUnknownError),
				ioDebug(list_to_atom(Sql)),
				{0,0,[""],["unknown db error"]}
		end.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mysql.erl
Type: application/octet-stream
Size: 16009 bytes
Desc: mysql.erl (Erlang Source File)
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20001205/233cd96c/attachment.obj>


More information about the erlang-questions mailing list