source: orange/Orange/testing/regression/tests_20/ @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1007 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

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.