关于sqlite的更多问题 [英] couple more questions about sqlite

查看:52
本文介绍了关于sqlite的更多问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在四处寻找并阅读,我还有一些问题

特别是关于SQLite,因为它与Python有关。


1.用于sqlite的当前模块是什么? sqlite3的?或者在Python 2.5之前不是



2. sqlite和pysqlite有什么区别?你需要两个吗,

只有一个,或者是同一个旧版本的一个?


3.命令之间的区别是什么行程序称为sqlite3

和你将用于Python的模块? (我知道前者让你的'b
你做普通的数据库事情而不用处理Python,但是如果你使用Python与数据库进行交互则需要
?)


谢谢!

I''ve been looking around and reading, and I have a few more questions
about SQLite in particular, as it relates to Python.

1. What is the current module to use for sqlite? sqlite3? or is that not
out until Python 2.5?

2. What''s the difference between sqlite and pysqlite? Do you need both,
just one, or is one an older version of the same thing?

3. What''s the difference between the command line program called sqlite3
and the module you would use with Python? (I know that the former let''s
you do normal database things without dealing with Python, but is it
necessary if you are using Python to interact with the DB?)

Thanks!

推荐答案


2什么是sqlite和pysqlite之间的区别?你是否需要两者,

只需一个,或者是同一个旧版本的一个?
2. What''s the difference between sqlite and pysqlite? Do you need both,
just one, or is one an older version of the same thing?



要从python访问你的数据库你需要两个(或者一些替代

到pysqlite)

To access your database from python you need both (or some alternative
to pysqlite)


3.命令行程序sqlite3

和你将用于Python的模块有什么区别? (我知道前者让你的'b
你做普通的数据库事情而不用处理Python,但是如果你使用Python与数据库进行交互则需要
?)
3. What''s the difference between the command line program called sqlite3
and the module you would use with Python? (I know that the former let''s
you do normal database things without dealing with Python, but is it
necessary if you are using Python to interact with the DB?)



slqite附带一个其他程序可以调用的库,以及一个

命令行界面

你可以在shell中使用它。 pysqlite需要图书馆,但是我不认为这是可能的

来获得一个没有另一个。


问候,

Andy

slqite comes with a library which other programs can call, and a
command line interface
that you can use from the shell. pysqlite needs the library but I
don''t think it is possible
to get one without the other.

Regards,
Andy


一个************** @ yahoo.co.uk 写道:

> 2。 sqlite和pysqlite有什么区别?你需要两者,只需要一个,还是一个旧版本的同一个东西?
>2. What''s the difference between sqlite and pysqlite? Do you need both,
just one, or is one an older version of the same thing?



要从python访问你的数据库你需要两个(或者一些替代

到pysqlite)


To access your database from python you need both (or some alternative
to pysqlite)



我可以理解这与MySQL是一回事,而mysqldb

是Python使用MySQL的必要模块。但是在2.5中,对于

的例子来说,这就是sqlite3,这就是你需要的全部,或者你还需要p
需要pysqlite吗?或者这两个不同的东西可以访问

sqlite系统吗? (我想我有点认为每种类型的数据库只会使用一个

标准模块,例如mysqldb是用于MySQL的
。) />

I can understand this in terms of MySQL being one thing, and mysqldb
being the necessary module for Python to use MySQL. But in 2.5, for
example, which comes with sqlite3, is this all you need, or do you still
need pysqlite? Or are these two different things that can access the
sqlite system? (I guess I kind of thought there would be just one
standard module used for each type of database, such as mysqldb being
the one used for MySQL.)


John Salerno写道:
John Salerno wrote:
一个************** @ yahoo.co.uk 写道:

2. sqlite和pysqlite有什么区别?你是否需要两者,

只需一个,或者是同一个旧版本的一个?
2. What''s the difference between sqlite and pysqlite? Do you need both,
just one, or is one an older version of the same thing?



要从python访问你的数据库你需要两个(或者一些替代

到pysqlite)

To access your database from python you need both (or some alternative
to pysqlite)



我可以理解这与MySQL是一回事,而mysqldb

是Python使用MySQL的必要模块。但是在2.5中,对于

的例子来说,这就是sqlite3,这就是你需要的全部,或者你还需要p
需要pysqlite吗?或者这两个不同的东西可以访问

sqlite系统吗? (我想我有点认为每种类型的数据库只会使用一个

标准模块,例如mysqldb是用于MySQL的
。)


I can understand this in terms of MySQL being one thing, and mysqldb
being the necessary module for Python to use MySQL. But in 2.5, for
example, which comes with sqlite3, is this all you need, or do you still
need pysqlite? Or are these two different things that can access the
sqlite system? (I guess I kind of thought there would be just one
standard module used for each type of database, such as mysqldb being
the one used for MySQL.)



你的困惑是可以理解的。当我宣布它将包含在Python 2.5中时,我开始查看sqlite



拼图统治。我最后得到了我的

实验模块的前面:


import sys

PY_VERSION = sys.version_info [ :2]

如果PY_VERSION> =(2,5):

import sqlite3

else:

从pysqlite2导入dbapi2作为sqlite3

print" Python:",sys.version

print" pysqlite:",sqlite3.version

print" sqlite:",sqlite3.sqlite_version


有趣的是,当时pysqlite2提供了一个版本的

底层C库, 2.4兼容但*晚于* 2.5a2附带的

版本[我从未检查过]。


所以,如果你想要的话现在尝试sqlite,下载pysqlite2并使用它2.4 / b
$ b。如果您有2.5版本候选版本,您也可以使用上面的

行中的版本检测代码尝试使用它来代码



我强烈建议学习SQL和Python DBAPI:

(1)从sqlite开始;它很棒,而且管理人员很少

(2)从sqlite网站下载命令行实用程序 - 你会

需要这对于最小的管理员来说,加上它对于快速的单行SQL

语句,窥视模式等很方便。


HTH,

John

Your confusion is quite understandable. I started looking at sqlite
when the announcement that it would be included in Python 2.5 came out.
Puzzlement reigned. I ended up with the following up the front of my
experimental module:

import sys
PY_VERSION = sys.version_info[:2]
if PY_VERSION >= (2, 5):
import sqlite3
else:
from pysqlite2 import dbapi2 as sqlite3
print "Python :", sys.version
print "pysqlite:", sqlite3.version
print "sqlite :", sqlite3.sqlite_version

Interestingly, at the time pysqlite2 was providing a version of the
underlying C library that was 2.4-compatible but *later* than the
version that came with 2.5a2 [I haven''t checked since].

So, if you want to try out sqlite now, download pysqlite2 and use it
with Python 2.4. If you have the 2.5 release candidate, you can try
your code with it as well, using version-detecting code along the above
lines.

I would strongly recommend for a learner of SQL and the Python DBAPI:
(1) start with sqlite; it''s great, and there''s minimal admin involved
(2) download the command-line utility from the sqlite website -- you''ll
need it for the minimal admin, plus it''s handy for quick one-line SQL
statements, peeking at the schema, etc.

HTH,
John


这篇关于关于sqlite的更多问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆