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

Discussion in 'Python' started by gdyren@gmail.com, Oct 17, 2008.

  1. Guest

    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
    , Oct 17, 2008
    #1
    1. Advertising

  2. Peter Otten Guest

    Re: no mistake but i didnt get what i want (with python module pymssql send information to the mssql)

    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
    Peter Otten, Oct 17, 2008
    #2
    1. Advertising

  3. Guest

    Re: no mistake but i didnt get what i want (with python modulepymssql send information to the mssql)

    On 10ÔÂ17ÈÕ, ÏÂÎç6ʱ41·Ö, Peter Otten <> wrote:
    > 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.
    , Oct 17, 2008
    #3
  4. Guest

    Re: no mistake but i didnt get what i want (with python modulepymssql send information to the mssql)

    On 10ÔÂ17ÈÕ, ÏÂÎç6ʱ41·Ö, Peter Otten <> wrote:
    > 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 .
    , Oct 17, 2008
    #4
  5. Peter Otten Guest

    Re: no mistake but i didnt get what i want (with python module pymssql send information to the mssql)

    wrote:

    > On 10月17æ—¥, 下åˆ6æ—¶41分, Peter Otten <> wrote:
    >> 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
    Peter Otten, Oct 17, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucrefy
    Replies:
    1
    Views:
    802
    gkochanowsky
    Oct 21, 2005
  2. Lucrefy
    Replies:
    0
    Views:
    337
    Lucrefy
    May 26, 2004
  3. Edgardo Rossetto

    Something like phpMyAdmin but for MSSQL?

    Edgardo Rossetto, Mar 28, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    17,151
    Rob Nicholson
    Apr 2, 2005
  4. Lennie
    Replies:
    0
    Views:
    103
    Lennie
    Dec 15, 2003
  5. chris
    Replies:
    3
    Views:
    71
    chris
    Oct 5, 2005
Loading...

Share This Page