Diferencia entre revisiones de «Usuario:Lmorillas/modulo programacion/python/Jython»
De WikiEducator
(Página creada con '{{MiTitulo | Jython}} {{Lectura | * http://jython.org/ * http://www.jython.org/jythonbook/en/1.0/ * http://jython.org/currentdocs.html }} {{Objetivo| Title=Instalación| * D…') |
|||
Línea 5: | Línea 5: | ||
* http://www.jython.org/jythonbook/en/1.0/ | * http://www.jython.org/jythonbook/en/1.0/ | ||
* http://jython.org/currentdocs.html | * http://jython.org/currentdocs.html | ||
+ | * http://cutter.rexx.com/~dkuhlman/jython_course_03.html | ||
}} | }} | ||
Línea 15: | Línea 16: | ||
$ java -jar jython_installer-2.5.2.jar | $ java -jar jython_installer-2.5.2.jar | ||
$ jython | $ jython | ||
+ | }} | ||
+ | |||
+ | |||
+ | {{Actividad| | ||
+ | == Un ejemplo con jython: Cliente de Twitter con Jython == | ||
+ | * http://www.jython.org/jythonbook/en/1.0/GUIApplications.html | ||
+ | * Instalar setuptools: | ||
+ | ** Descarga http://peak.telecommunity.com/dist/ez_setup.py | ||
+ | ** Ejecuta: | ||
+ | $ jython ez_setup.py | ||
+ | * Instalar python-twitter: http://code.google.com/p/python-twitter/ (! atención con las rutas) | ||
+ | $ jython easy_install python-twitter | ||
+ | }} | ||
+ | |||
+ | {{Actividad| | ||
+ | == Acceso a Bases de Datos con zxJDBC == | ||
+ | * http://www.jython.org/jythonbook/en/1.0/DatabasesAndJython.html | ||
+ | Un ejemplo con Oracle: | ||
+ | <source lang="python"> | ||
+ | from com.ziclix.python.sql import zxJDBC | ||
+ | d, u, p, v = "dbc:oracle:thin:@172.30.6.190:1521/enlaces5", 'dai1', 'tiger', "oracle.jdbc.driver.OracleDriver" | ||
+ | |||
+ | db = zxJDBC.connect(d, u, p, v) | ||
+ | |||
+ | cursor = db.cursor() | ||
+ | |||
+ | cursor.execute("SELECT banner FROM sys.v_$version") | ||
+ | |||
+ | for l in cursor.fetchall(): | ||
+ | print l | ||
+ | |||
+ | cursor.execute("SELECT * from emp") | ||
+ | |||
+ | for l in cursor.fetchall(): | ||
+ | print l | ||
+ | |||
+ | print db.dbname | ||
+ | print db.dbversion | ||
+ | print cursor.updatecount | ||
+ | print zxJDBC.paramstyle | ||
+ | </source> | ||
+ | |||
}} | }} |
Revisión de 20:39 25 may 2012
$ java -jar jython_installer-2.5.2.jar $ jython |
Un ejemplo con jython: Cliente de Twitter con Jython
$ jython ez_setup.py
$ jython easy_install python-twitter
|
Acceso a Bases de Datos con zxJDBCUn ejemplo con Oracle: from com.ziclix.python.sql import zxJDBC d, u, p, v = "dbc:oracle:thin:@172.30.6.190:1521/enlaces5", 'dai1', 'tiger', "oracle.jdbc.driver.OracleDriver" db = zxJDBC.connect(d, u, p, v) cursor = db.cursor() cursor.execute("SELECT banner FROM sys.v_$version") for l in cursor.fetchall(): print l cursor.execute("SELECT * from emp") for l in cursor.fetchall(): print l print db.dbname print db.dbversion print cursor.updatecount print zxJDBC.paramstyle
|