From owner-freebsd-questions Thu Jan 16 6: 3: 2 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 56A1937B401 for ; Thu, 16 Jan 2003 06:03:01 -0800 (PST) Received: from mail.adelphia.net (pa-plum1b-166.pit.adelphia.net [24.53.161.166]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67CDA43E4A for ; Thu, 16 Jan 2003 06:03:00 -0800 (PST) (envelope-from wmoran@potentialtech.com) Received: from potentialtech.com ([172.16.0.95]) by mail.adelphia.net (8.12.3/8.12.3) with ESMTP id h0GE3wAg006762; Thu, 16 Jan 2003 09:03:59 -0500 (EST) (envelope-from wmoran@potentialtech.com) Message-ID: <3E26AFD1.5040508@potentialtech.com> Date: Thu, 16 Jan 2003 08:12:49 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.1) Gecko/20021127 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Paul Hamilton Cc: freebsd-questions@FreeBSD.ORG Subject: Re: How can data be inserted into a MySQL DB using C code? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Paul Hamilton wrote: > Hi All, > > Step one was collecting the data, Step two is to somehow get the info into a > MySQL DB. > > I am monitoring a serial port's CTS line, and need to get the fact that it's > changed state logged into the DB. > > I can use C and/or PHP. Perl is beyond me :-( (I have trouble enough just > trying to add Perl modules). This is OT for the FreeBSD lists. MySQL has several list where you'll have more people subscribed who can help you. However, it sounds like you want to use the MySQL C API. If you install the MySQL client, the C API is included (if memory serves). All you have to do is write your code to use it, and be sure to give the proper options to cc when you compile to link in the MySQL libraries. This page starts the docs on the MySQL C API. http://www.mysql.com/doc/en/C.html > The C program runs continuously, monitoring the CTS bit, so I thought it > would be nice to dump the info straight into the MySQL DB. > > As a backup, I suppose, I could dump the 'date/time' and 'CTS-Open-Closed' > into a text file, then once a day, run a PHP script to import the files > contents into the MySQL DB. However, that means I wouldn't get any live > data. That sounds pretty clunky. > I know there is the MySQL++ project, but I had problems trying to get that > to function, and my C++ knowledge is negligible. > > Any help, or tips would be grateful. > > Cheers, > > Paul Hamilton -- Bill Moran Potential Technologies http://www.potentialtech.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message