[PD] MySql database accessing with PureData ?

Frank Barknecht fbar at footils.org
Wed Dec 17 16:46:11 CET 2003


Hallo,
Jean Jacques hat gesagt: // Jean Jacques wrote:

> Unfortunately i don't know anything about python excepted that i
> should learn it !  Could you give me an estimation of the time
> needed by a newbie to script a MySql reader for pd ?

This very much depends on how comfortable and experienced you are with
programming. I learned the basics of Python in about an afternoon, and
I was only slightly experienced in Perl at that time. Start with Guido
van Rossums Python tutorial, it's a short read and lots of fun, too.

For Database access I would highly recommend using SQLObject from
http://sqlobject.org/, which is a wrapper around several databases. It
makes getting started with database programming in Python *very* fast. 

This is a complete DB app in Python:

# start
from SQLObject import *

__connection__ = MySQLConnection(
    host='localhost', db='sqlobject_test',
    user='sqlobject_test', passwd='sqltest')

class Person(SQLObject):

    firstName = StringCol(length=100)
    middleInitial = StringCol(length=1, default=None)
    lastName = StringCol(length=100)

if __name__ == "__main__":
    Person.createTables()
    msp = Person.new("Miller", "S", "Puckettte")
    print "%s wrote Pd" % msp.lastName
    print "Oops, spelling error!"
    msp.lastName = "Puckette"
    print msp
    
# end

After that, msp is correctly saved in the Database, because all
DB-actions are transparent and automatically written or read when
accessing the attributes like "msp.lastName"

ciao
-- 
 Frank Barknecht                               _ ______footils.org__




More information about the Pd-list mailing list