热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Python2.2.3中的SQLite-SQLiteinPython2.2.3

Ivewrittenaweb-appinpythonusingSQLiteanditrunsfineonmyserverathome(withapacheand

I've written a web-app in python using SQLite and it runs fine on my server at home (with apache and python 2.5.2). I'm now trying to upload it to my web host and there servers use python 2.2.3 without SQLite.
Anyone know of a way to use SQLite in python 2.2.3 e.g. a module that I can upload and import? I've tried butchering the module from newer versions of python, but they don't seem to be compatible.
Thanks,
Mike

我使用SQLite在python中编写了一个web应用程序,它在家里的服务器上运行正常(使用apache和python 2.5.2)。我现在正在尝试将其上传到我的网络主机,并且服务器使用不带SQLite的python 2.2.3。任何人都知道在python 2.2.3中使用SQLite的方法,例如我可以上传和导入的模块吗?我试过从较新版本的python中屠杀模块,但它们似乎不兼容。谢谢,迈克

4 个解决方案

#1


There is no out-of-the-box solution; you either have to backport the SQLlite module from Python 2.5 to Python 2.2 or ask your web hoster to upgrade to the latest Python version.

没有开箱即用的解决方案;你要么必须将SQLlite模块从Python 2.5反向移植到Python 2.2,要么让你的web主机升级到最新的Python版本。

Python 2.2 is really ancient! At least for security reasons, they should upgrade (no more security fixes for 2.2 since May 30, 2003!).

Python 2.2非常古老!至少出于安全考虑,他们应该进行升级(自2003年5月30日起,不再需要2.2的安全修复程序!)。

Note that you can install several versions of Python in parallel. Just make sure you use "/usr/bin/python25" instead of "/usr/bin/python" in your scripts. To make sure all the old stuff is still working, after installing Python 2.5, you just have to fix the two symbolic links "/usr/bin/python" and "/usr/lib/python" which should now point to 2.5. Bend them back to 2.2 and you're good.

请注意,您可以并行安装多个版本的Python。只需确保在脚本中使用“/ usr / bin / python25”而不是“/ usr / bin / python”。为了确保所有旧的东西仍在工作,在安装Python 2.5之后,你只需要修复两个符号链接“/ usr / bin / python”和“/ usr / lib / python”,它现在应该指向2.5。把它们弯回2.2,你很好。

#2


Look here: http://oss.itsystementwicklung.de/download/pysqlite/

看这里:http://oss.itsystementwicklung.de/download/pysqlite/

From the release notes (http://oss.itsystementwicklung.de/trac/pysqlite/browser/doc/install-source.txt)

从发行说明(http://oss.itsystementwicklung.de/trac/pysqlite/browser/doc/install-source.txt)

  1. Python: Python 2.3 or later
  2. Python:Python 2.3或更高版本

You may not be able to do what you're trying to do.

你可能无法做你想做的事情。

#3


If you have shell access to your web server, you can probably build you're own version of Python and SQLite. This will let you use the latest version. Download the source code, then when you configure it, do something like "./configure --prefix=$HOME/packages".

如果您具有对Web服务器的shell访问权限,则可以构建自己的Python和SQLite版本。这将让您使用最新版本。下载源代码,然后在配置时,执行类似“./configure --prefix = $ HOME / packages”的操作。

Next, fiddle around with your .profile, or .bashrc or whatever it is to make sure $HOME/packages/bin comes first in your path. This will cause your private Python to override the one installed by your web server.

接下来,使用.profile或.bashrc或其他任何内容来确保$ HOME / packages / bin在您的路径中排在第一位。这将导致您的私有Python覆盖您的Web服务器安装的私有Python。

This page might give you a little more information for how to do this on a server like Dreamhost: http://wiki.dreamhost.com/Python

此页面可能会为您提供有关如何在Dreamhost等服务器上执行此操作的更多信息:http://wiki.dreamhost.com/Python

#4


In case anyone comes across this question, the reason why neither pysqlite nor APSW are available for Python 2.2 is because Python 2.3 added the simplified GIL API. Prior to Python 2.3 it required a lot of code to keep track of the GIL. (The GIL is the lock used by Python to ensure correct behaviour while multi-threading.)

如果有人遇到这个问题,那么pysqlite和APSW都不适用于Python 2.2的原因是因为Python 2.3添加了简化的GIL API。在Python 2.3之前,需要大量代码来跟踪GIL。 (GIL是Python使用的锁,用于确保多线程时的正确行为。)

Doing a backport to 2.2 would require ripping out all the threading code. Trying to make it also be thread safe under 2.2 would be a nightmare. There was a reason they introduced the simplified GIL API!

执行2.2的反向移植需要删除所有线程代码。试图使它在2.2下也是线程安全将是一场噩梦。他们推出简化的GIL API是有原因的!

I am still astonished at just how popular older Python versions are. APSW for Python 2.3 is still regularly downloaded.

我仍然对旧的Python版本的流行程度感到惊讶。 APSW for Python 2.3仍然定期下载。


推荐阅读
author-avatar
航19830_811
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有