Spam Free Email

Anti-spam ideas, tools and services

January 24th, 2006

Notes on native Erlang MySQL module

There were a few things that were worth mentioning that I did not like about the native Erlang MySQL module. But mostly I’m quite happy with it.

The biggest thing that I did not like was the fact that it returns everything as strings. It gives you the column information and tell you that it’s a long or a double or whatever, but the data is still a string.

I wrote a function into my wrapper that looks at the column information and casts it to an appropriate type based on what was in MySQL. Occasionally I have to recast it, but it is mostly when it is a string in the database and I was to use the information as an atom.

I also had most of my code based off the ”list of tuples” design from the OTP ODBC application. The native MySQL module uses a ”list of lists” design, so while I was recasting things about I also changed the list into a tuple. This is minor to me, as it was really just to prevent rewriting a lot of my code.

The single greatest advantage to using this module is connection pooling. That alone will save my MySQL server tons of new connections and logins.

January 24th, 2006

Native support for MySQL in Erlang

I was reading through my RSS feeds today when I noticed a new post at http://www.planeterlang.com. It mentioned a native Erlang application to communicate with MySQL. Since I have been having some issues with my ODBC connection to MySQL I thought I’d give it a try.

The native Erlang application actually send binary data back and forth between your Erlang node and the MySQL server, instead of translating test into something that the client send and then it comes back to the server. It seems to not only be faster, but much more stable then using ODBC to connect to MySQL.

When I was doing a lot of ODBC command from a windows workstation (WinXP) I was having problems where the odbc driver would give out. So far the native Erlang application for MySQL has been solid as a rock.

When using ODBC, the request was going from my application, to the OTP ODBC application, which started a program outside of Erlang to connect to the ODBC drivers that eventually made a connection to the MySQL server. In the case of Linux, I was using MyODBC and UnixODBC and that means that five programs had wot work right before things would get to MySQL.

Now Erlang talk directly to the MySQL server, so I have a wrapper in my application, which talk to the native Erlang application and then that talks directly to MySQL. Two applications internal to Erlang instead of 2 inside and at least 2 outside of Erlang.

I’m a happy camper, as I have rewritten a complete version just to accommodate the new native Erlang application in my anti-spam server. Luckily I had isolated most of my SQL commands into one module :-)

http://support.process-one.net/doc/display/CONTRIBS/Yxa

|