인문지식 처리와 프로그래밍2020 5.21-28과제 종합응용2

soook
Soook (토론 | 기여) 사용자의 2020년 5월 27일 (수) 22:20 판

이동: 둘러보기, 검색

#!/usr/bin/python

import pyodbc 

# required interface data values are
server = 'tcp:digerati.aks.ac.kr' 
database = 's_soook' 
username = 'guest' 
password = 'guest' \

dic ={}

def readData():	

	cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
	cursor = cnxn.cursor()

	cursor.execute("select id, 압운 from dbo.YunData$ order by id") #SQL 문 실행

	row = cursor.fetchone() 		# Select 문의 결과 세트 중에서 첫번째 데이터를 가져온다
	
	while row: 						#가져온 데이터가 있을 때까지 반복 수행
		dic[row[1]] = row[0]
		row = cursor.fetchone() # 그 다음 데이터를 가져온다


readData()

def main():	

	cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
	cursor = cnxn.cursor()

	cursor.execute("select id, 원문 from dbo.sevenData$ order by id") #SQL 문 실행

	row = cursor.fetchone() 		# Select 문의 결과 세트 중에서 첫번째 데이터를 가져온다
	
	while row: 						#가져온 데이터가 있을 때까지 반복 수행
	if ( a % 2 ==0) {}
		print( '{0}\t{1}'.format(row[1], row[0]) ) 	#가져온 데이터를 출력한다
		row = cursor.fetchone() # 그 다음 데이터를 가져온다



main()




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

import pyodbc 
import sys

# required interface data values are
server = 'tcp:digerati.aks.ac.kr' 
database = 's_soook' 
username = 'guest' 
password = 'guest' 


def main():	

	cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
	cursor = cnxn.cursor()

	cursor.execute("select id, 원문 from dbo.sevenData$ order by id")	

	row = cursor.fetchone()		
	
	while row: 						
		print( '{0}\t{1}'.format(row[1], row[0]) )
		row = cursor.fetchone()

sys.stdout = open("soookodbc1.html", 'w', encoding = 'utf8')
print('<!DOCTYPE html>')
print('<html>')
print('<head>')
print('<body>')
print(main())
print('</body>')
print('</head>')
print('</html>')