블로그 이미지
개발 블로그였지만 맛집을 더 많이 올리고있어서 잡동사니로 재 명명함ㅋㅋ 꽃현주

카테고리

분류 전체보기 (24)
Essay (1)
Development (12)
Tip/Info (8)
Book (1)
Item (2)
Total
Today
Yesterday

'python drop table'에 해당되는 글 1건

  1. 2014.02.13 sqlite excute query

Python에서 간단히

(1) sqlite db연결하고,

(2) table 만들고,

(3) table에 data 삽입하기

#!/usr/bin/env python
#-*- coding: utf-8 -*-

import os, sys
import sqlite3

def makeSqliteTable(rows):
    conn= sqlite3.connect("dbName")
    conn.text_factory= str
    c= conn.cursor()
    c.execute("DROP TABLE IF EXISTS student_info")
    c.execute("CREATE TABLE student_info (kor_name text, address text, job text, age text)")
    c.executemany("INSERT INTO student_info VALUES(?,?,?,?)",rows) 
    conn.commit()
    conn.close()

def main():
    rows= []

    rows.append("홍길동", "경기도","대학생","24살")
    rows.append("이상화", "경기도","빙상여제","26살")

    makeSqliteTable(rows)

if __name__== "__main__":
    main()



Posted by 꽃현주
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함