From: Kashia Buch Date: 2006-12-12T23:22:44+09:00 Subject: Re: connect to MySQL Database Hi, > I run Mac OS X Tiger, ruby 1.8.4 (from sources) and MySQL 5.0.27 (from > sources). > > I wan't to create a script which is called by pure-ftpd's uploadscript > functionality - clamav scans each uploaded file - and store the scan > results directly into a MySQL database. > > What's the recommended way to do this? I would do it along these lines (untested): require 'og' # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/165163 require 'clamscanner' class ClamavScanResult is Timestamped property :path, String property :result, Result end Og.start(:store => :mysql, :name => 'clamavdb', :user => 'testuser', :password => 'private', :classes => [ClamavScanResult]) # scan this file file = ARGV[0] # first argument is the file/path ? clamav = ClamScanner.new res = clamav.scan( file ) ClamavScanResult.create_with(:path => file, :result => res) __END__ Of course, the 'recommended' way could way differ from my own opinion on how this should be done. :P This has the downside that using Og instead of a pure mysql lib that the (startup) speed is a little worse. The plus side is, you get to switch to postgresql very fast (if you ever get that idea :P) and that the script is quite small and easy to read. Enjoy. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/