Koozali.org: home of the SME Server

Python access to MySQL database on SME Server 7.3

Offline dgs

  • ***
  • 63
  • +0/-0
Python access to MySQL database on SME Server 7.3
« on: February 18, 2008, 01:33:04 AM »
I am seeking some assistance and or advice running a python scripts on SME 7.3.

Basically what I wish to do is monitor some ASCII data on a serial port analyse the data within a received line and write that data to a table within a MySQL database. I have selected to use Python with modules PySerial and  python-mysql. I am aware that any additions, changes or modifications to a base SME distribution have security implications  so my questions are as follows.

I have loaded and tested the PySerial module without problem and done some testing without error, but to date I have had no luck getting python-mysql loaded onto my SME 7.3 test box. I have trawled through contribs org and many python and mysql sites and have either missed the answer completely or come up empty.

I installed  gcc with yum install gcc which resolved the first batch of errors but to date I cannot compile or install the python-mysql onto an SME box. I an a relative newbie here and do not want to load anything else onto the SME box that I do no understand the implications of.  Can anyone point me in the right direction here? No flames please, I have tried to resolve my own problems first but am getting nowhere, which is why I am asking for help.

Is my intended approach the best ways to achieve some relatively simple programming on an SME 7.3 box? If not what would be a better approach?


  $ tar xfz MySQL-python-1.2.1.tar.gz
  $ cd MySQL-python-1.2.1
  $ # edit site.cfg if necessary
  $ python setup.py build
  $ sudo python setup.py install # or su first

I am getting errors at the console at the line $ python setup.py build which make no sense to me, can anyone tell me what I am missing?

Thanks for an assistance.




Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
Re: Python access to MySQL database on SME Server 7.3
« Reply #1 on: February 18, 2008, 04:48:18 AM »
Please NEVER use your production server to make or compile software!

After this advice, I have make it for you. You can download from:
http://www.unixlan.com.ar/sme7/

Choose mysql-py23.tar.gz

Extract and install as usual way with YUM.

If you want to compile software, use a test server or install vmware in your desktop PC. Then install SME and then all devel packages.

For install devel packages search the forum.

For learn how to make packages for SME, read:

http://mirror.contribs.org/smeserver/contribs/gordonr/devguide/html/devguide.html
http://wiki.contribs.org/Releasing_Contribs
http://wiki.contribs.org/Package_Modification
« Last Edit: February 18, 2008, 04:54:55 AM by Normando »

Offline dgs

  • ***
  • 63
  • +0/-0
Re: Python access to MySQL database on SME Server 7.3
« Reply #2 on: February 18, 2008, 05:11:03 AM »
Many thanks Normando, I think I can get going now thanks to your assistance.

I should have mentioned none of this is done on a production box and I understand why compilers are not installed in the base distribution. 

I'll have a good read through the links provided.  Once again, thank you for your assistance it has been invaluable.

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
Re: Python access to MySQL database on SME Server 7.3
« Reply #3 on: February 18, 2008, 05:23:33 AM »
You are welcome :pint:

And always install only RPM packages into SME (only via YUM, not rpm -ivh...), never install from sources.
In this case, you can make an RPM with the command:

Quote
python setup.py bdist_rpm
« Last Edit: February 18, 2008, 05:28:45 AM by Normando »