Hallo, Luigi Rensinghoff hat gesagt: // Luigi Rensinghoff wrote:
Yes i can acces the database from python, entering some lines of python:
db = MySQLdb.connect("localhost", "root", "gigiroot", "sfx_database") sql = """SELECT * FROM soundfile where description like '%birds%""" cursor.execute(sql) data = cursor.fetchall() print data.
but from PD it does not work
Could you elaborate "does not work" a bit? Some debugging info or so?
Attached is a very stripped down example how to access a db from pyext. I use sqlite as a db-backend in the code, the file is hardcoded to "/tmp/pypd.db". Change as wanted.
You probably want to initialize the db with commands like this:
BEGIN TRANSACTION; create table soundfile (description text); INSERT INTO soundfile VALUES('abc'); INSERT INTO soundfile VALUES('mybirds'); INSERT INTO soundfile VALUES('songbirds'); INSERT INTO soundfile VALUES('birdsong'); COMMIT;
Beware: the code isn't very effective. For example normally you should not slurp in the whole result set in one go etc.
Frank Barknecht _ ______footils.org_ __goto10.org__