any effort getting sqlalchemy to work on ironpython is going on ?

191 views
Skip to first unread message

sakesun

unread,
Sep 11, 2008, 11:01:38 PM9/11/08
to sqlalchemy

I need sqlalchemy to work on ironpython (1.2 or 2.0b)
sqlalchemy fail on ironpython even with simple use case
like create simple Table definition.

>>> from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
>>> metadata = MetaData()
>>> users_table = Table('users', metadata,
... Column('id', Integer, primary_key=True),
... Column('name', String),
... Column('fullname', String),
... Column('password', String)
... )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: Index was outside the bounds of the array.

and wonder if any effort or interest already exists in running sa & ip
together ?
If none, then I may want to take on this (need it for my work)
and will be appreciate some clue to speed myself up.

Thanks

Michael Bayer

unread,
Sep 12, 2008, 11:11:50 AM9/12/08
to sqlal...@googlegroups.com

On Sep 11, 2008, at 11:01 PM, sakesun wrote:

>
>
> I need sqlalchemy to work on ironpython (1.2 or 2.0b)
> sqlalchemy fail on ironpython even with simple use case
> like create simple Table definition.
>
>>>> from sqlalchemy import Table, Column, Integer, String, MetaData,
>>>> ForeignKey
>>>> metadata = MetaData()
>>>> users_table = Table('users', metadata,
> ... Column('id', Integer, primary_key=True),
> ... Column('name', String),
> ... Column('fullname', String),
> ... Column('password', String)
> ... )
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> IndexError: Index was outside the bounds of the array.

wow, thats pretty bad.

I wonder if the question is more, "is any effort underway getting
IronPython to work like Python" ?

SQLAlchemy does work with Jython and really didnt need any changes
other than database dialect stuff. So its not like we're performing
any black magic with arrays in our Table object.

I am curious what the issue is above, but also I think the agenda with
IronPython is that folks would be calling out to all Microsoft
libraries to do everything, like Linq. So I'm not aware of any effort
to get SQLA going on IronPython but it would definitely be much
appreciated if there were.

Kyle Schaffrick

unread,
Sep 12, 2008, 4:48:02 PM9/12/08
to sqlal...@googlegroups.com
On Fri, 12 Sep 2008 11:11:50 -0400
Michael Bayer <mik...@zzzcomputing.com> wrote:
>
> On Sep 11, 2008, at 11:01 PM, sakesun wrote:
>
> >
> >
> > I need sqlalchemy to work on ironpython (1.2 or 2.0b)
> > sqlalchemy fail on ironpython even with simple use case
> > like create simple Table definition.
> >
> >>>> from sqlalchemy import Table, Column, Integer, String,
> >>>> MetaData, ForeignKey
> >>>> metadata = MetaData()
> >>>> users_table = Table('users', metadata,
> > ... Column('id', Integer, primary_key=True),
> > ... Column('name', String),
> > ... Column('fullname', String),
> > ... Column('password', String)
> > ... )
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > IndexError: Index was outside the bounds of the array.
>
> wow, thats pretty bad.
>

This traceback seems to be either incomplete, or the interactive
interpreter doesn't like the way it was typed, since it appears to be
saying the error is in something on the console input. I might try this
and see, the console editing in IronPython is kinda spartan and quirky.

SA doesn't do *that* much black magic. It might be just enough to expose
a bug in IronPython, or a false dependency in SA, but I seriously doubt
it would involve the list subscript operator. :)

> I wonder if the question is more, "is any effort underway getting
> IronPython to work like Python" ?
>

The last time I played with IronPython, it was 1.1 (I think) and the
language itself is quite complete. The only strangeness with the
language proper is that unicode and str primitives are one in the same,
you have to use bytes to get an unencoded string (which is probably fine
as CPython 3.0 is going to mandate this also. I just wonder if they will
do it *that* way).

Also, the class implementation needs a little looking at, as there seems
to be no old-style classes, you get a new-style class without inheriting
from object (or anything else).

These I discovered when I tweaked PyYAML to run on IronPython. It
depended on str and unicode being differentiable, and it's "RTTI" would
puke because of this. Also, codec was absent; see below.

> SQLAlchemy does work with Jython and really didnt need any changes
> other than database dialect stuff. So its not like we're performing
> any black magic with arrays in our Table object.
>

Since SA runs on Jython it should be relatively free of false
dependencies on interpreter implementation details (such as GC behavior
and datatype details). That probably goes a good way towards making it
work on IronPython.

> I am curious what the issue is above, but also I think the agenda
> with IronPython is that folks would be calling out to all Microsoft
> libraries to do everything, like Linq.

I don't know enough about Linq to say whether it would be able to be
molded into a pythonic interface for IronPython. I tend to doubt it
because of that "language integrated" part, but there might be a
meta-interface to whatever sorts of things Linq manipulates. There's
probably also value in using python libraries one is already familiar
with, for people such as me (a Python guy who may want to run on .NET,
as opposed to a .NET guy who wants to code in Python)

Also, I think IronPython and IronRuby are trying to stay compatible with
Mono too. I say that because dynamic languages on the CLR are being
touted as major hotness when combined with Silverlight, and Moonlight is
a "Microsoft endorsed" Silverlight implementation built on Mono.

> So I'm not aware of any
> effort to get SQLA going on IronPython but it would definitely be
> much appreciated if there were.
>

It would be pretty cool :)

The biggest gaps in IronPython last time I used it were Python standard
library support, which they appear to be working on. For instance, the
codec module and (i think) the pickle module weren't present at all,
although the former was available with slightly altered/incomplete
semantics as "_codec".

I think the big hold-up on the libraries is that the IronPython guys
seem to be thoughtfully integrating the CLR and Python features
together, and I guess that takes some time. For instance, there is
(was?) a bug to allow Python classes implementing a pickle interface to
be able to be serialized with CLR's System.Runtime.Serialization, and
[Serializable] CLR classes to be picklable.

Anyway, just some thoughts on the matter...

-Kyle

Dan Eloff

unread,
Sep 13, 2008, 3:07:49 AM9/13/08
to sqlal...@googlegroups.com
On Thu, Sep 11, 2008 at 10:01 PM, sakesun <sak...@gmail.com> wrote:

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> IndexError: Index was outside the bounds of the array.
>

I've had that before on complex python packages (e.g. Jinja2), I'm
pretty sure it's an internal error in IronPython, but beats me as to
where it's happening. You should try running it under the debugger.

-Dan

sakesun

unread,
Sep 18, 2008, 10:20:37 PM9/18/08
to sqlalchemy
Just try IronPython beta5. And it work now. :D
Reply all
Reply to author
Forward
0 new messages