Database development with Jython, SQLAlchemy, and Hibernate (#70)
Mr. Frank J Wierzbicki bio
30min Intermediate
categories:
jython
Jython is an implementation of the language Python written in Java to run on the JVM. Jython was designed to integrate seamlessly with existing Java code and as such can be used to bring dynamic language features to existing Java code bases without requiring extensive rewriting to realize the benefits of using Python. Jython has a very mature codebase, its first release occurring over ten years ago. The latest stable version of Jython (2.2) was released in August and the next version of Jython (version 2.5) is progressing well. The purpose of this talk is to demonstrate current and upcoming features of Jython language that can be used to accelerate day to day development.
Reading and manipulating data from relational databases is the bread and butter of many professional developers. Relational databases provide excellent examples with which to demonstrate the utililty of Jython. This talk will illustrate many of the powerful features of Jython by detailing several strategies for database access.
This presentation is targeted at Python developers who want to learn more about Jython and about using Jython to manipulate relational databases. Some experience with relational databases is assumed. Familiarity with SQLAlchemy or other ORM framework is helpful.
Throughout this talk, I will demonstrate code using Jython's interative console. I will also demonstrate how to access the built-in implementation of db-api which is built on JDBC (Java's low level db api).
SQLAlchemy is a popular Python ORM framework which allows access to the database to occur through objects and object relationships without necessarily resorting to detailed work in SQL. SQLAlchemy's use of the Data Mapper pattern to create a mapping between relational data and objects will be explained. Techniques for the use of SQLAlchemy through Jython will be demonstrated.
Hibernate is a popular Jave framework which is analogous to SQLAlchemy. Hibernate also uses a Data Mapper strategy to create its mapping between relational data and objects. I will compare and contrast Hibernate's approach with that of SQLAlchemy with plenty of example code.
I will also demo some new language features of Jython. In particular I will cover the relationship between Java Annotations and Python decorators in Jython. Annotations in Java look like this:
//Java Annotation
@MyDecorator(param1 = 1, param2 = "hello")
public static void hello() { ... }
And python decorators look like this:
#Python decorator
@my_decorator(param1=1, param2="hello")
def hello():
...
When Jython is compiled to a .class file the decorator is exposed as a Java annotation, also Jython can see Java annotations mapped as decorators. At the time of this writing the details of this process are still being worked out, but will be ready to demo at the time of this talk.
Reading and manipulating data from relational databases is the bread and butter of many professional developers. Relational databases provide excellent examples with which to demonstrate the utililty of Jython. This talk will illustrate many of the powerful features of Jython by detailing several strategies for database access.
This presentation is targeted at Python developers who want to learn more about Jython and about using Jython to manipulate relational databases. Some experience with relational databases is assumed. Familiarity with SQLAlchemy or other ORM framework is helpful.
Throughout this talk, I will demonstrate code using Jython's interative console. I will also demonstrate how to access the built-in implementation of db-api which is built on JDBC (Java's low level db api).
SQLAlchemy is a popular Python ORM framework which allows access to the database to occur through objects and object relationships without necessarily resorting to detailed work in SQL. SQLAlchemy's use of the Data Mapper pattern to create a mapping between relational data and objects will be explained. Techniques for the use of SQLAlchemy through Jython will be demonstrated.
Hibernate is a popular Jave framework which is analogous to SQLAlchemy. Hibernate also uses a Data Mapper strategy to create its mapping between relational data and objects. I will compare and contrast Hibernate's approach with that of SQLAlchemy with plenty of example code.
I will also demo some new language features of Jython. In particular I will cover the relationship between Java Annotations and Python decorators in Jython. Annotations in Java look like this:
//Java Annotation
@MyDecorator(param1 = 1, param2 = "hello")
public static void hello() { ... }
And python decorators look like this:
#Python decorator
@my_decorator(param1=1, param2="hello")
def hello():
...
When Jython is compiled to a .class file the decorator is exposed as a Java annotation, also Jython can see Java annotations mapped as decorators. At the time of this writing the details of this process are still being worked out, but will be ready to demo at the time of this talk.
Files:
# Permalink
.