ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • <PYTHON>SQLite3 접속
    Flower in my dev/Python 2015. 4. 6. 14:29
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    import sqlite3
     
    con = sqlite3.connect("test.db")
    cursur = con.cursor()
     
    data = [(1"Korea"), (2"USA"), (3"China"), (4"Japan")]
     
    cursor.execute("create table world(no, nation)")
     
    cursor.executemany("insert into world values(?,?)", data)
     
    print 'Last rowid:' + str(cursor.lastrowid)
    print 'Row count:' + str(cursor.rowcount)
     
    cursor.execute("select * from world")
    for row in cursor:
        print row[1]
     
    cursor.execute("update world set nation='France' where no=4")
     
    cursor.execute("select * from world")
    print cursor.fetchall()
     
    cursor.close()
    db.commit()
    db.close()
     
    cs

    'Flower in my dev > Python' 카테고리의 다른 글

    <PYTHON>pyinotify 설치  (0) 2015.04.10
    <PYTHON> twisted 설치  (0) 2015.04.08
    <PYTHON>PostgreSql 접속  (0) 2015.04.06
    <PYTHON>vim config  (0) 2015.04.06
    <PYTHON>[sys]  (0) 2015.04.01

    댓글

Designed by Tistory.