python db select 문 출력하기

    [python] python db select 문 출력하기

    python과 db 를 연결한 내용은 conn 이다. execute 메서드를 호출해 sql명령어를 입력한다. cur = conn.cursor() cur.execute("select * from ptck.news_save ") cr = cur.fetchall() for x in cr: print(x) 함수로 sql 문을 사용하는 방법이다. cur 은 db connect 에 대한 내용이다. 위의 cur = conn.cursor() 로 보면된다. #함수로 필요한 데이터 호출 def readDB(self,schema,table,colum): sql = "select {colum} from {schema}.{table}".format(colum=colum,schema=schema,table=table) try: ..