that it wasn't that hard to get it to work for a (very) simple test.
This is by no means complete or even good, but I am keeping the code
here: http://jython.svn.sourceforge
The three files are a simple test (sqla.py), a monkey-patched version of database/mysql.py (mysql.py) and the "svn diff" against the sqlalchemy repository as of today (mysql.diff), so I can keep track of the changes I made to get things to work. mysql.py can be pasted on top of the real one, then you can run jython (latest from the 2.3 branch) and it works, at least on my
machine :)
The table I'm testing against on mysql:
mysql> select * from users;
+----+-------+
| id | name |
+----+-------+
| 1 | user1 |
| 2 | user2 |
+----+-------+
The test code looks like this:
from sqlalchemy import *
db = create_engine('mysql://username:password@localhost/mydb')
metadata = BoundMetaData(db)
users_table = Table('users', metadata, autoload=True)
s = users_table.select()
r = s.execute()
print r.fetchall()
And produces output that looks like this:
[(1L, 'user1'), (2L, 'user2')]
One thing I had to do was switch "re" to "sre" because our "re" is
missing at least one method. I'll file a bug or fix it (maybe
tonight).
I posted this to the sqlalchemy list -- and Michael Bayern
sounded very enthusiastic about helping to get sqlalchemy running on
Jython.
View comments