Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Connect to MySQL

If you have a question or need help, this is the place to be.
Post Reply
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Connect to MySQL

Post by sjolof »

I┬┤m trying to find a way to send results from my serialport to my MySQL-database.
I have compiled MySQLdb and that almost seems to work...
But when executing python script in eg it says that it can┬┤t find _mysql...

Have anyone made this earlier and maybe can tell me how?

Thanks in advance!
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Connect to MySQL

Post by Bitmonster »

The problem is, that EG uses another environment as normal Python. You have two options I guess:

1. Running EG from source:
http://www.eventghost.org/wiki/HowTo:Ru ... rom_source

2. Add the needed files to the /eg directory.
Grab all _mysql* files and the "MySQLdb" folder from Python's Lib/site-packages directory and move them all to /eg in your EG folder. EventGhost.exe should then be able to find them.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Connect to MySQL

Post by sjolof »

Thanks for helping out.
I┬┤m trying "your nbr 2" and when I apply changes on script I just get:

Error compiling script.
Traceback (most recent call last):
IndentationError: unexpected indent (22, line 1)


An when executing:

Python Script
Traceback (most recent call last):
AttributeError: Compile instance has no attribute 'code'


My script looks like:

import MySQLdb

conn = MySQLdb.connect (host = "localhost",
user = "testuser",
passwd = "testpass",
db = "test")
cursor = conn.cursor ()
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]
cursor.close ()
conn.close ()


Can someone help me out? Pleeeaaase....
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Connect to MySQL

Post by Bitmonster »

IndentationError: unexpected indent (22, line 1)

So check line 1 of your script and you will see that you have a improper indentation of your code.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Connect to MySQL

Post by sjolof »

You are correct of course...
I┬┤m just a stupid noob that havent done any programming earlier, but now the script seems to work just fine.
Having some trouble to connect to the database, but I┬┤m thinking of putting it locally instead. Then I guess it will be fairly simple to connect.

Thank┬┤s for your help!
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Connect to MySQL

Post by sjolof »

Just wanted to tell you that it works as it should now.
Had to put my mysql locally because my webhost didn┬┤t allow me to connect.

Thanks for your help.
Post Reply