if you want to submit a patch for me ill look over it; but i dont think i have the resources to "support" 2.2...
On Jun 29, 2006, at 7:42 AM, Jens Diemer wrote: > > I have hacked a little. And a short test works with Python 2.2 and > MySQLdb v0.9.2... > > I have used two backported scripts: > > sets.py from Python 2.4 > datetime.py from PyPy http://codespeak.net/svn/pypy/release/0.8.x/ > pypy/lib/datetime.py > > > I must insert the follow line in many files: > from __future__ import generators > > > Then i have made a stupid fix for pickle.HIGHEST_PROTOCOL > > > Big Problem is a couple of dict.pop() :( > I can't patch the builtin dict, so i must replace the code in > __init__.py and schema.py: > > replace: > >>>kwargs.pop(<<< > with: > >>>dict_pop(kwargs, <<< > > dict_pop is a small function and i have make it globally available > with: > > __builtin__.dict_pop = dict_pop > > > > The total number of the changes are not that much. I think it's > manageable. I consider to continue. > > Any feedback ? > > > -- > Mfg. > > Jens Diemer > > > ---- > CMS in pure Python CGI: http://www.pylucid.org > #!/usr/bin/python > # -*- coding: UTF-8 -*- > > """ > Backports: > > sets.py from Python 2.4 > datetime.py from PyPy http://codespeak.net/svn/pypy/release/0.8.x/ > pypy/lib/datetime.py > > Patches: > ======== > > types.PickleType().__init__() - line 200: > > stupid fix! > > replace: > def __init__(self, protocol=pickle.HIGHEST_PROTOCOL, pickler=None): > > with: > def __init__(self, protocol=1, pickler=None): > > > > __init__.py - line 90 and schema.py > > Many dict.pop() -> solution: __builtin__.dict_pop > > replace: >>>> kwargs.pop(<<< > with: >>>> dict_pop(kwargs, <<< > > so, the function dict_pop() is used ;) > """ > > > import sys, __builtin__ > > # make sets.py and datetime.py available: > sys.path.insert(0,"python_backports") > > > > def dict_pop(dict, key, default_value): > """ > In Python 2.2 dict.pop() does not exists. > > replace: > value = dict.pop('key', default_value) > with: > value = dict_pop(dict, 'key', default_value) > """ > if dict.has_key(key): > result = dict[key] > del dict[key] > else: > result = default_value > > return result > > __builtin__.dict_pop = dict_pop > > > > > > > import sqlalchemy > > > engine = sqlalchemy.create_engine( > "mysql://UserName:[EMAIL PROTECTED]/DatabaseName" > ) > connection = engine.connect() > > result = connection.execute("SHOW VARIABLES;") > print result > result = list(result) > print len(result), "lines" > print "First line:", result[0] > print > > metadata = sqlalchemy.BoundMetaData(engine) > users_table = sqlalchemy.Table('users', metadata, > sqlalchemy.Column('user_id', sqlalchemy.Integer, > primary_key=True), > sqlalchemy.Column('user_name', sqlalchemy.String(40)), > sqlalchemy.Column('password', sqlalchemy.String(10)) > ) > metadata.engine.echo = True > try: > users_table.create() > except Exception, e: > print Exception.__name__, e > print > > users_table = sqlalchemy.Table('users', metadata, autoload=True) > print list(users_table.columns)[0].name > print > > i = users_table.insert() > print i > > i.execute(user_name='Mary', password='secure') > print > i.execute({'user_name':'Tom'}, {'user_name':'Fred'}, > {'user_name':'Harry'}) > print > > s = users_table.select() > print s > print > > r = s.execute() > print r > print > print r.fetchone() > print > print r.fetchall() > > connection.close()Using Tomcat but need to do more? Need to support > web services, security? > Get stuff done quickly with pre-integrated technology to make your > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users