Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > no mistake but i didnt get what i want (with python module pymssqlsend information to the mssql)

Reply
Thread Tools

no mistake but i didnt get what i want (with python module pymssqlsend information to the mssql)

 
 
gdyren@gmail.com
Guest
Posts: n/a
 
      10-17-2008
the code is below:
import pymssql
conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password
= "xxxx",database = "test")
print "connecting success"
cursor = conn.cursor()
cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)",
("1","nju","9:13","ustc","test"))
cursor.close()
conn.close()
in the idle:
connecting success

then i get into the database :test and find that there is nothing in
the table bbs_test.
i don't know why
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      10-17-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> the code is below:
> import pymssql
> conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password
> = "xxxx",database = "test")
> print "connecting success"
> cursor = conn.cursor()
> cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)",
> ("1","nju","9:13","ustc","test"))
> cursor.close()
> conn.close()
> in the idle:
> connecting success
>
> then i get into the database :test and find that there is nothing in
> the table bbs_test.
> i don't know why


Because you did not commit your changes with conn.commit().

Peter
 
Reply With Quote
 
 
 
 
gdyren@gmail.com
Guest
Posts: n/a
 
      10-17-2008
On 10月17日, 下午6时41分, Peter Otten <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > the code is below:
> > import pymssql
> > conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password
> > = "xxxx",database = "test")
> > print "connecting success"
> > cursor = conn.cursor()
> > cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)",
> > ("1","nju","9:13","ustc","test"))
> > cursor.close()
> > conn.close()
> > in the idle:
> > connecting success

>
> > then i get into the database :test and find that there is nothing in
> > the table bbs_test.
> > i don't know why

>
> Because you did not commit your changes with conn.commit().
>
> Peter- 隐藏被引用文字 -
>
> - 显示引用的文字 -


???how to.
 
Reply With Quote
 
gdyren@gmail.com
Guest
Posts: n/a
 
      10-17-2008
On 10月17日, 下午6时41分, Peter Otten <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > the code is below:
> > import pymssql
> > conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password
> > = "xxxx",database = "test")
> > print "connecting success"
> > cursor = conn.cursor()
> > cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)",
> > ("1","nju","9:13","ustc","test"))
> > cursor.close()
> > conn.close()
> > in the idle:
> > connecting success

>
> > then i get into the database :test and find that there is nothing in
> > the table bbs_test.
> > i don't know why

>
> Because you did not commit your changes with conn.commit().
>
> Peter- 隐藏被引用文字 -
>
> - 显示引用的文字 -


thank you . I know how .
 
Reply With Quote
 
Peter Otten
Guest
Posts: n/a
 
      10-17-2008
(E-Mail Removed) wrote:

> On 10鏈17鏃, 涓嬪崍6鏃41鍒, Peter Otten <(E-Mail Removed)> wrote:
>> (E-Mail Removed) wrote:
>> > the code is below:
>> > import pymssql
>> > conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password
>> > = "xxxx",database = "test")
>> > print "connecting success"
>> > cursor = conn.cursor()
>> > cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)",
>> > ("1","nju","9:13","ustc","test"))
>> > cursor.close()

conn.commit() # This makes the inserted record permanent
>> > conn.close()
>> > in the idle:
>> > connecting success

>>
>> > then i get into the database :test and find that there is nothing in
>> > the table bbs_test.
>> > i don't know why

>>
>> Because you did not commit your changes with conn.commit().


> ???how to.


Call conn.commit() before conn.close() like shown above.

Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I didnt get MCTS 70-528 Logo And 70-536 also Ganesh MCTS 1 10-21-2008 09:55 PM
Steve Irwin - Didnt take long Jonathan Rhys-Lewis UK VOIP 0 09-04-2006 11:15 AM
About .Net FrameWord Component AutoUpdater didnt work?? Lucrefy ASP .Net 1 10-21-2005 02:34 PM
About .Net FrameWork Component AutoUpdater didnt work Lucrefy ASP .Net 0 05-26-2004 06:58 AM
DIDNT GET MY CERTICATE JOHNDAVID MCSE 46 05-06-2004 06:35 PM



Advertisments