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

soook
이동: 둘러보기, 검색

#!/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>')



#!/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.seven10Data$ 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>')

login as: soook
soook@dh.aks.ac.kr's password:
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-72-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

724 packages can be updated.
0 updates are security updates.

New release '18.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Wed May 27 17:44:10 2020 from 125.132.153.101
soook@dh:~$ ls
Hello3.py  public_html
soook@dh:~$ cd public_html
soook@dh:~/public_html$ cd cgi-bin
soook@dh:~/public_html/cgi-bin$ python3 S0528.py
Traceback (most recent call last):
  File "S0528.py", line 32, in <module>
    print(main())
  File "S0528.py", line 19, in main
    cursor.execute("select id, 원문 from dbo.seven10Data$ order by id")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid                                                                              continuation byte
soook@dh:~/public_html/cgi-bin$








login as: soook
soook@dh.aks.ac.kr's password:
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-72-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

724 packages can be updated.
0 updates are security updates.

New release '18.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Wed May 27 23:35:01 2020 from 14.4.245.152
soook@dh:~$ ls
Hello3.py  public_html
soook@dh:~$ cd public_html
soook@dh:~/public_html$ cd cgi-bin
soook@dh:~/public_html/cgi-bin$ python3 S0528.py
Traceback (most recent call last):
  File "S0528.py", line 32, in <module>
    print(main())
  File "S0528.py", line 19, in main
    cursor.execute("select id, 원문 from dbo.seven10Data$ order by id")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid                                                                              continuation byte
soook@dh:~/public_html/cgi-bin$