Python SQLite3 模块的替代方案 - 也许是 MySQL
我们有一个网站,它使用 SQL(当前为 SQLite3)来存储竞赛和参赛者信息。服务器端语言是 python &使用模块 sqlite3。事实证明,虚拟主机运行 python 2.4 & sqlite3 模块仅在 python 2.6/2,7 & 中可用向上。
因此,我需要能够仅使用 python 2.4 将参赛者写入 python 中的 SQL 数据库。
如果我能获得 SSH 访问权限,那就太好了。安装 python 2.7,但是当然这个网络主机希望我们的企业购买 VPS 访问权限来执行此操作&这是不可能的。
我读过,我可以使用以下代码导入 python SQL 模块,但当我在网站上运行此脚本(在 CGI-bin 文件夹中)时失败:
try:
import sqlite3
except ImportError:
from pysqlite import dbapi2 as sqlite3
我正在考虑只使用 MySQL,因为我听说它是更快,但有没有 python MYSQL 模块&它可以在 python 2.4 上运行吗?你对我如何写作有什么建议吗?将竞赛条目存储到我的 python 2.4 中的 SQL 数据库中?
We have a website that uses SQL (currently SQLite3) to store entrants into a competition & the server side language is python & uses the module sqlite3. It turns out that the webhost runs python 2.4 & the module sqlite3 is only available in python 2.6/2,7 & up.
So I need to be able to write competition entrants to my SQL database in python using only python 2.4.
It would be great if I could get SSH access & install python 2.7 but ofcourse this webhost wants our business to purchase VPS access to do this & this is not possible.
I have read that I could import python SQL modules using the following code but it fails when I run this script on the website(in the CGI-bin folder):
try:
import sqlite3
except ImportError:
from pysqlite import dbapi2 as sqlite3
I am thinking of just using MySQL because I have heard it is faster but is there a python MYSQL module & does it work on python 2.4? Do you have any advice on how I can write & store competition entries to my my SQL database in python 2.4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,当您的虚拟主机尚未安装 pysqlite 时,您无法使用它。当然,还有其他库可以访问不同的数据库,例如MySQL。如果可以的话,这些又取决于您的网络主机:他必须安装相应的数据库模块。
此外,大多数 SQL 数据库都是独立的服务,需要单独安装和维护。
只需询问您的虚拟主机哪些数据库可用(如果有)。
顺便说一句,“你听说 MySQL 更快”:对于小型数据库来说,这可能是错误的,因为 SQLite 相当快,并且可能受益于它可以本地访问数据这一事实,而使用 MySQL 时,将会有一些通信开销。
Obviously you cannot use pysqlite when your webhost has not installed it. There are, of course, other libraries to access different databases, such as MySQL. If you can you those depends, again, on your webhost: He will have to install the respective database module.
Moreover, most SQL databases are standalone services that need to be installed and maintained separately.
Just ask you webhost which databases are available, if any.
By the way, "you heard MySQL is faster": For small databases this is probably wrong, as SQLite is pretty fast and might benefit from the fact that it can access data locally, whereas with MySQL, there will be some communication overhead.