[issue7572] Strabge issue : cursor.commit() with sqlite

2009-12-24 Thread lakshmipathi

New submission from lakshmipathi :

Hi all,
I'm new user to python and sqlite, let me know if i'm wrong or it's
sqlite issue.When I uncomment the line from below program it works -as
expected. But even when it's commented It works for first time.-As per
doc,without commit -all changes will be lost- am i right?

Issue : Running the program once without commit works for the first time
but not the next time.

Try changing the return value from 'OSS' to 'GNU' and comment/uncomment
the commit line.
--
Here is my program:
-
import sqlite3
def loopy():
return 'OSS'
#get connection object 
conn = sqlite3.connect("/tmp/example")
#get curson obj. and invoke execute
cur = conn.cursor()

conn.create_function("loopy",0,loopy)

cur.execute("insert into stk values (loopy())""")
#commit changes.
#conn.commit()  # **Uncomment this line and run again***

# read values
cur.execute("select * from stk")
for row in cur:
print row

cur.close()
-

--
messages: 96851
nosy: lakshmipathi
severity: normal
status: open
title: Strabge issue : cursor.commit() with sqlite
type: behavior
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue7572>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7572] Strabge issue : cursor.commit() with sqlite

2009-12-29 Thread lakshmipathi

lakshmipathi  added the comment:

ok..let me put this question ,in different manner.
Here is my code (example2)
--
import sqlite3
def loopy():
return 'GNU'
#get connection object 
conn = sqlite3.connect("/tmp/example2")
#get curson obj. and invoke execute
cur = conn.cursor()
cur.execute('''create table stk (txt text)''')
#insert a single record
conn.create_function("loopy",0,loopy)
t=(loopy(),)
cur.execute("insert into stk values (?)",t)
#I have close it without committing. -So my record length == 0
cur.close()
#But when  i open again new cursor cur1
cur1=conn.cursor()
cur1.execute("select * from stk")
row = cur1.fetchall()
# i expect this assert to pass - since there is no record 
assert len(row) < 1

---
I used sqlite3 /tmp/example2 and select * from stk returned zero records
as expected.
--
So commit refers to committing to Database not with in the program.

--

___
Python tracker 
<http://bugs.python.org/issue7572>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com