This article illustrates how to access to local or remote MySQL server from the client API in Python, C and PHP.
Refer to MySQL server installing and test to install a MySQL server on your Acme Board with the database used on this examples.
Install MySQLdb module from Debian repository by typing:
~# apt-get update ~# apt-get install python-mysqldb
The try this example:
~# python addrlist.py (1L, 'Acme Systems srl', '+39 (06) 99-12-187', 'www.acmesystems.it') (2L, 'Atmel Corporate', '+1 (408) 441-0311', 'www.atmel.com') (3L, 'Digikey', '+1 (800) 344-4539', 'www.digikey.com') (4L, 'Mouser', '+39 02 575 065 71', 'www.mouser.com')
Install MySQL C client library from Debian repository by typing:
~# apt-get update ~# apt-get install libmysqlclient-dev
The try this example:
Compiling it in this way:
~# gcc addrlist.c -lmysqlclient -o addrlist
~# ./addrlist 1 Acme Systems srl +39 (06) 99-12-187 www.acmesystems.it 2 Atmel Corporate +1 (408) 441-0311 www.atmel.com 3 Digikey +1 (800) 344-4539 www.digikey.com 4 Mouser +39 02 575 065 71 www.mouser.com
Install the PDO driver:
~# apt-get update ~# apt-get install php5-mysql
Restart lighttpd web server:
~# /etc/init.d/lighttpd restart
Save in /var/www/ the following PHP script:
Open a browser on the following url:
We suggest to enable the display_errors parameter on line 531 of /etc/php5/cgi/php.ini file during the development:
display_errors = On
and restart the lighttpd web server:
~# /etc/init.d/lighttpd restart