Changeset 10088:09c3a1a940fa in orange


Ignore:
Timestamp:
02/08/12 16:21:10 (2 years ago)
Author:
crt.gorup@…
Branch:
default
rebase_source:
5da846fa174d16bae957544cd8ba02c2fbe3430f
Message:

Documentation for Orange.data.sql.

Location:
docs/reference/rst
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.data.sql.rst

    r9992 r10088  
    44 
    55The :class:`sql` module provides access to relational databases from Orange. 
    6 It currently supports `MySql <http://www.mysql.com/>`_  through 
    7 `MySQL for Python <http://sourceforge.net/projects/mysql-python/>`_ 
    8 and `Postgres <http://www.postgresql.org>`_ through `Psycopg <http://initd.org/psycopg/>`_. 
    9  
     6It currently supports: 
     7- `MySql <http://www.mysql.com/>`_  through `MySQL for Python <http://sourceforge.net/projects/mysql-python/>`_, 
     8- `Postgres <http://www.postgresql.org>`_ through `Psycopg <http://initd.org/psycopg/>`_, 
     9- `sqlite <http://www.sqlite.org/>`_ through `sqlite3 <http://docs.python.org/library/sqlite3.html>`_. 
    1010 
    1111:class:`SQLReader` and :class:`SQLWriter` classes require connection string based on 
     
    1414Examples of valid connection strings: 
    1515 
     16- sqlite://database.db/ 
    1617- mysql://user:password@host/database 
    1718- mysql://host/database?debug=1 
    1819- postgres://user@host/database?debug=&cache= 
    19 - postgres:///full/path/to/socket/database 
    2020- postgres://host:5432/database 
    2121 
    2222**Attribute Names and Types** 
    2323 
    24 Rows returned by an SQL query have to be converted into Orange Instances. 
     24Rows returned by an SQL query have to be converted into Orange examples. 
    2525Each column in a row has to be converted into a certain feature type. The 
    2626following conversions between SQL and Orange types are used: 
     
    3030- Other features are converted to continuous Orange features. 
    3131- The attribute in ``class_name`` is set as the class features. If no ``class_name`` is set, the column with the 
    32   name "class" in the returned SQL query is set as the class attribute. If no such column exists, the last 
    33   column is set as the class features. 
     32   name "class" in the returned SQL query is set as the class attribute. If no such column exists, the last 
     33   column is set as the class features. 
     34 
     35.. note:: When reading ``sqlite`` data table into :class:`Orange.data.Table` all columns are casted into :class:`Orange.feature.String`. 
     36 
     37**Examples** 
     38 
     39The following example populates the `sqlite <http://www.sqlite.org/>`_ database with data from :class:`Orange.data.Table`. 
     40 
     41.. literalinclude:: code/sql-example.py 
     42   :lines: 1-6 
     43 
     44Using the existing `sqlite <http://www.sqlite.org/>`_ database one can fetch back the data into :class:`Orange.data.Table`. 
     45 
     46.. literalinclude:: code/sql-example.py 
     47   :lines: 8-24 
     48 
     49The output of the last example is:: 
     50 
     51  150 instances returned 
     52  Output data domain: 
     53  StringVariable 'sepal length' 
     54  StringVariable 'sepal width' 
     55  StringVariable 'petal length' 
     56  StringVariable 'petal width' 
     57  StringVariable 'iris' 
     58  First instance : ['5.09999990463', '3.5', '1.39999997616', '0.20000000298', 'Iris-setosa'] 
     59  22 instances returned 
    3460 
    3561.. autoclass:: Orange.data.sql.SQLReader 
Note: See TracChangeset for help on using the changeset viewer.