sqlite3 bug ?? [英] sqlite3 bug??

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

问题描述

我犹豫不决,但是......


我正在使用Ubuntu Feisty:

* Python 2.5.1(r251:54863, 2007年5月2日,16:56:35)

[gCC 4.1.2(Ubuntu 4.1.2-0ubuntu4)] on linux2

* SQLite版本3.3.13


假设我运行以下程序:

import sqlite3


conn = sqlite3.connect(''example'' )

c = conn.cursor()


#创建表

c.execute(''''''创建表股票

(日期文本,trans文本,符号文本,

数量真实,价格真实)''''''

#插入一行数据

c.execute(""" insert into stocks

values(''2006-01-05'',' '买'',''RHAT'',100,35.14)""")


然后我进入sqlite:

% sqlite3示例

sqlite3select *来自股票;


返回0行。我在正确的目录中。我已经遇到了这个问题,其他一些sqlite3数据库工作我用python完成了这个问题,

所以我觉得有些东西可疑。我已经尝试用Ruby做了类似的练习,并且他们工作得很好。


其他人遇到这些问题吗?

解决方案

2007年6月17日,标记卡特< me@privacy.netwrote:


我犹豫不决问,但是......


我正在使用Ubuntu Feisty:

* Python 2.5.1(r251:54863,2007年5月2日,16: 56:35)

[GCC 4.1.2(Ubuntu 4.1.2-0ubuntu4)] on linux2

* SQLite版本3.3.13


假设我运行以下程序:

import sqlite3

conn = sqlite3.connect(''example'')


c = conn.cursor()


#创建表格

c.execute(''''''创建表库存

(日期文本,反式文本,符号文本,

数量真实,价格真实)''''''


#插入一行数据

c.execute(""" insert into stocks
值(''2006-01-05'',''购买'',''RHAT'',100,35.14)""")


然后我进入sqlite:

%sqlite3示例

sqlite3select *来自股票;


它返回0行。我在正确的目录中。我已经遇到了这个问题,其他一些sqlite3数据库工作我用python完成了这个问题,

所以我觉得有些东西可疑。我已经尝试用Ruby做了类似的练习,并且他们已经工作正常了。


其他人遇到这些问题了吗?



参见 http://www.python.org/dev/peps/pep-0249/ (强调我的):


.commit()


将任何挂起的事务提交到数据库。 *注意

如果数据库支持自动提交功能,则必须首先关闭
。*可以提供接口方法

把它重新打开。


(这应该是常见问题解答...)


- David


mark carter写道:


我犹豫不决,但是......



不要:-)


我正在使用Ubuntu Feisty:

* Python 2.5.1(r251 :linux86上的54863,2007年5月2日,16:56:35)

[GCC 4.1.2(Ubuntu 4.1.2-0ubuntu4)]


假设我运行以下程序:

import sqlite3


conn = sqlite3.connect(''示例'')


c = conn.cursor()


#创建表

c.execute(' '''''创建表库存

(日期文本,反式文本,符号文本,

数量真实,价格真实)''''')


#插入一行数据

c.execute(""" insert into stocks

值(''2006-01-05'',''买'',''RHAT'',100,35.14)""")

>
然后我进入sqlite:

%sqlite3示例

sqlite3select *来自股票;


它返回0行。我在正确的目录中。我已经遇到了这个问题,其他一些sqlite3数据库工作我用python完成了这个问题,

所以我觉得有些东西可疑。我已经尝试用Ruby做了类似的练习,并且他们已经工作正常了。


其他人遇到这些问题了吗?



conn.commit()怎么样?


彼得


< blockquote> On Sun,2007-06-17 at 12:59 +0100,mark carter写道:


我犹豫不决,但是......


我正在使用Ubuntu Feisty:

* Python 2.5.1(r251:54863,2007年5月2日,16:56:35)

[GCC 4.1.2(Ubuntu 4.1.2-0ubuntu4)] on linux2

* SQLite版本3.3.13


假设我运行以下程序:

import sqlite3

conn = sqlite3.connect(''example'')


c = conn。光标()


#创建表格

c.execute(''''''创建表库存

(日期文本,trans text,symbol text,

qty real,price real)''''')


#插入一行数据

c.execute(""" insert into stocks

values(''2006-01-05'',''BUY'',''RHAT'',1 00,35.14)""")


然后我进入sqlite:

%sqlite3示例

sqlite3select *来自股票;


它返回0行。



你的程序没有调用conn.commit()。 Python的DB-API指定默认情况下连接在事务中运行

。如果没有提交,交易将在程序结束时回滚。


-

Carsten Haese
http://informixdb.sourceforge.net

I hesitate to ask, but ...

I''m using Ubuntu Feisty:
* Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
* SQLite version 3.3.13

Suppose I run the following program:
import sqlite3

conn = sqlite3.connect(''example'')
c = conn.cursor()

# Create table
c.execute(''''''create table stocks
(date text, trans text, symbol text,
qty real, price real)'''''')

# Insert a row of data
c.execute("""insert into stocks
values (''2006-01-05'',''BUY'',''RHAT'',100,35.14)""")

and then I go into sqlite:
% sqlite3 example
sqlite3select * from stocks ;

It returns 0 rows. I''m in the right directory. I have experienced this
problem with some other sqlite3 database work I have done with python,
so I''m figuring there is something fishy going on. I''ve tried doing
similar exercises with Ruby, and they have worked OK.

Anyone else getting these problems?

解决方案

On 6/17/07, mark carter <me@privacy.netwrote:

I hesitate to ask, but ...

I''m using Ubuntu Feisty:
* Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
* SQLite version 3.3.13

Suppose I run the following program:
import sqlite3

conn = sqlite3.connect(''example'')
c = conn.cursor()

# Create table
c.execute(''''''create table stocks
(date text, trans text, symbol text,
qty real, price real)'''''')

# Insert a row of data
c.execute("""insert into stocks
values (''2006-01-05'',''BUY'',''RHAT'',100,35.14)""")

and then I go into sqlite:
% sqlite3 example
sqlite3select * from stocks ;

It returns 0 rows. I''m in the right directory. I have experienced this
problem with some other sqlite3 database work I have done with python,
so I''m figuring there is something fishy going on. I''ve tried doing
similar exercises with Ruby, and they have worked OK.

Anyone else getting these problems?

See http://www.python.org/dev/peps/pep-0249/ (emphasis mine):

.commit()

Commit any pending transaction to the database. *Note that
if the database supports an auto-commit feature, this must
be initially off.* An interface method may be provided to
turn it back on.

(This really should be a FAQ...)

-- David


mark carter wrote:

I hesitate to ask, but ...

Don''t :-)

I''m using Ubuntu Feisty:
* Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
* SQLite version 3.3.13

Suppose I run the following program:
import sqlite3

conn = sqlite3.connect(''example'')
c = conn.cursor()

# Create table
c.execute(''''''create table stocks
(date text, trans text, symbol text,
qty real, price real)'''''')

# Insert a row of data
c.execute("""insert into stocks
values (''2006-01-05'',''BUY'',''RHAT'',100,35.14)""")

and then I go into sqlite:
% sqlite3 example
sqlite3select * from stocks ;

It returns 0 rows. I''m in the right directory. I have experienced this
problem with some other sqlite3 database work I have done with python,
so I''m figuring there is something fishy going on. I''ve tried doing
similar exercises with Ruby, and they have worked OK.

Anyone else getting these problems?

How about conn.commit()?

Peter


On Sun, 2007-06-17 at 12:59 +0100, mark carter wrote:

I hesitate to ask, but ...

I''m using Ubuntu Feisty:
* Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
* SQLite version 3.3.13

Suppose I run the following program:
import sqlite3

conn = sqlite3.connect(''example'')
c = conn.cursor()

# Create table
c.execute(''''''create table stocks
(date text, trans text, symbol text,
qty real, price real)'''''')

# Insert a row of data
c.execute("""insert into stocks
values (''2006-01-05'',''BUY'',''RHAT'',100,35.14)""")

and then I go into sqlite:
% sqlite3 example
sqlite3select * from stocks ;

It returns 0 rows.

Your program doesn''t call conn.commit(). Python''s DB-API specifies that
a connection operate in a transaction by default. The transaction is
rolled back at the end of the program if it''s not committed.

--
Carsten Haese
http://informixdb.sourceforge.net


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

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