source: orange/Orange/doc/modules/sql-new4.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 714 bytes checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
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:        iris.tab
5# Referenced:  orngSQL.htm
6
7import orange, orngSQL, orngTree
8
9data = orange.ExampleTable("iris")
10print "Input data domain:"
11for a in data.domain.variables:
12    print a
13w = orngSQL.SQLWriter('mysql://user:somepass@localhost/test')
14w.create('iris', data)
15
16r = orngSQL.SQLReader('mysql://user:somepass@puhek/test')
17r.execute('SELECT "petal width", "petal length" FROM iris WHERE "sepal length"<5.0')
18data = r.data()
19print "\n%d instances returned" % len(data)
20print "Output data domain:"
21for a in data.domain.variables:
22    print a
Note: See TracBrowser for help on using the repository browser.