source: orange/orange/doc/modules/ @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 1007 bytes checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

1# Description: Writes a data set to and reads from an SQL database
2# Category:    file formats
3# Classes:     ExampleTable, orngSQL.SQLReader, orngSQL.SQLWriter
4# Uses:
5# Referenced:  orngSQL.htm
7import orange, orngSQL, orngTree
9data = orange.ExampleTable("iris")
10print "Input data domain:"
11for a in data.domain.variables:
12    print a
13r = orngSQL.SQLReader('mysql://user:somepass@localhost/test')
14w = orngSQL.SQLWriter('mysql://user:somepass@localhost/test')
15# the following line only works with mysql because it uses the enum type.
16w.create('iris', data, 
17    renameDict = {'sepal length':'seplen',
18        'sepal width':'sepwidth',
19        'petal length':'petlen',
20        'petal width':'petwidth'},
21    typeDict = {'iris':"""enum('Iris-setosa', 'Iris-versicolor', 'Iris-virginica')"""})
24r.execute("SELECT petwidth, petlen FROM iris WHERE seplen<5.0;")
25data =
26print "\n%d instances returned" % len(data)
27print "Output data domain:"
28for a in data.domain.variables:
29    print a
Note: See TracBrowser for help on using the repository browser.