本文介绍了开箱即用的数据库支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嘿那里。 我想知道Python是否有开箱即用的支持数据库功能或类似数据库的功能。 例如很多共享主机都安装了Python,但没有安装Python扩展程序,灵活的安装程序会安装它,但大多数 我真的在寻找像捆绑的SQLite这样的东西 with PHP这些天。或任何标准方式连接到开箱即用的通用 数据库,即MySQL。 感谢阅读。 Alex Biddle。 解决方案 Python 2.5'的标准库包括pysqlite。对于任何其他数据库,或任何以前发布的Python版本,你需要单独下载。 当然,共享主机太懒了(并且不感兴趣 支持Python)执行20秒下载和安装,将在未来20年左右升级到Python 2.5,因此 我怀疑pysqlite成为标准库的一部分有任何 帮助解决你所说的问题(在例如段落中)。 Alex 你想要一匹小马吗?今天可以使用pysqlite *,并且不会因为你自己的软件包安装或捆绑而过于繁重。在接近 的范围内,我们看到它*将*成为所包含电池的一部分,所以 单独安装只是暂时的麻烦。 但目前的Python版本还有另一个数据库电池。 试试这个: import bsddb 没有SQL支持,相反,这给你一个类似dict的数据库访问权限 (值必须是字符串,所以你必须将列序列化为某些东西 喜欢XML,JSON,YAML等): import bsddb db = bsddb.hashopen(" testdb.db") db [" Paul"] ="""< user name =" Paul" id =" 12345" />""" db [" Alex"] ="""< user name =" Alex" id =" 12346" />""" print db.keys() del db [" Paul"] print db.keys() db.close() 感谢您的信息。不,谢谢你的小马小马评论。我不能 安装我自己的版本,因为我在共享服务器上,当然 理想情况下我不喜欢。 2006年7月3日,Shane Hathaway< sh *** @ hathawaymix.org写道: 这就是你真正需要VPS(虚拟专用服务器)的原因。与网络主机相似的费用是 ,但您可以选择自己的技术和 版本。有几家公司想到: http://westhost.com/ http://jvds.com/ http://linode.com/ 我正在使用Westhost,如果你要求它提供Python 2.2,但是我用编译了Python 2.4。我甚至不必问我是否允许这样做。允许这样做。 :-) Shane 是的,理想情况下,VPS将是最佳选择。在美国托管似乎比英国的便宜,我不知道为什么。如果我要打造一个Python网络应用程序,那么我会去VPS,现在虽然我只是用PHP做了。 On 2006年7月3日09:45:35 -0700,BartlebyScrivener< rp ******* @ gmail.comwrote: 与bx的关系很大;开箱即用如果它得到了MySQL的支持,那么Python可以吸引人们的大众市场 去寻找廉价的东西,这是不可能的打扰升级Python让 单独安装databasefoo支持。目前这个市场更多或仅仅是由PHP占用的b $ b。 是的...我在我的本地Linux服务器上安装了MySQL支持等/> 但是我/不能/在共享主机环境中这样做。 对于它的价值,我确实尝试过搜索,但是我猜测我的参数 是错误的。如果它每周出现两次,或许还有一个案例 的需求和供应呢? Hey there.I was wondering whether Python had any support out-of-the-box fordatabase functionality, or database-like functionality.For instance a lot of shared hosts have Python installed, but not theMySQL extension, the flexible of these would install it, but most ofthe time they wouldn''t bother.I was really looking for something like SQLite which ships bundledwith PHP these days. Or any standard way of connecting to genericdatabases out of the box, i.e. MySQL.Thanks for reading.Alex Biddle. 解决方案Python 2.5''s standard library includes pysqlite. For any other DB, orany previous release of Python, you need separate downloads.Of course, shared hosts that are too lazy (and uninterested insupporting Python) to perform a 20-seconds download and install, willhardly be upgrading to Python 2.5 in the next 20 years or so, thereforeI doubt that pysqlite becoming part of the standard library is of anyhelp to the problem you have stated (in the "for instance" paragraph).AlexWould you like a pony with that? pysqlite *is* available today, and is notoverly onerous to install or bundle with your own package. And on the nearhorizon, we see that it *will* be part of the included batteries, soseparate installation is only a temporary nuisance.But there is another database battery available in current Python versions.Try this:import bsddbNo SQL support, instead this gives you a dict-like access to the database(values must be strings, so you have to serialize columns into somethinglike XML, JSON, YAML, etc.):import bsddbdb = bsddb.hashopen("testdb.db")db["Paul"]="""<user name="Paul" id="12345"/>"""db["Alex"]="""<user name="Alex" id="12346"/>"""print db.keys()del db["Paul"]print db.keys()db.close()Thanks for the info. No thanks for the smarmy "pony" comment. I can''tinstall my own version because I''m on a shared server, of courseideally I wouldn''t like to be.On 7/3/06, Shane Hathaway <sh***@hathawaymix.orgwrote:This is why you really want a VPS (virtual private server). The cost issimilar to a web host but you get to choose your own technologies andversions. Several companies come to mind: http://westhost.com/ http://jvds.com/ http://linode.com/I''m using Westhost, which provides Python 2.2 if you ask for it, but Icompiled Python 2.4 instead. I didn''t even have to ask whether I wasallowed to do that. :-)ShaneYeah, ideally a VPS would be the way to go. In the US hosting seems tobe cheaper than here in the UK, I don''t know why. If I was going tomake a Python web app then I would go VPS, nowadays though I just makedo with PHP.On 3 Jul 2006 09:45:35 -0700, BartlebyScrivener <rp*******@gmail.comwrote:The big deal with "out of the box" is that if it had support from theoutset for MySQL then Python could appeal to the mass market of peoplewho go for cheap-o hosts that can''t be bothered to upgrade Python letalone install databasefoo support. Currently this market is more orless solely occupied by PHP.Yes... I have installed MySQL support etc. on my local Linux serverbut I /can''t/ do that on a shared hosting environment.For what it''s worth, I did try searching, but I guess my parametreswere the wrong ones. If it comes up twice a week, perhaps its a caseof demand and supply anyway? 这篇关于开箱即用的数据库支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 12:23