Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 28 | 29 | 30 |
Tags
- VM 호스트 주소
- Regex
- SFTP
- react #router
- OpenSCAD
- debian
- Notepadplus
- PyLucene
- 윈도우
- React #React-Table
- 정규표현식
- Basic Auth
- Notepad++
- 임펠러
- springboot #spring #jackson
- Printer Driver
- 노트패드뿔뿔
- startfile
- 보안연결실패
- PDFCreator
- mailutils
- Windows
- Notepad
- firefox 파이어폭스
- 가상머신호스트
- cifsutils
- 소스 <script> 로딩 실패
- FTP
- linux ssh root debian
Archives
- Today
- Total
JJC's 테크니컬 다이어리
Python SQLite 코드 샘플-select 본문
#!/opt/bin/python
# -*- coding: cp949 -*-
import sys
sys.path.append('/opt/lib/python2.4/site-packages')
from pysqlite2 import dbapi2 as sqlite
from datetime import date
import csv, os, string,cgi
print "Content-Type: text/html"
print
# Create a connection to the database file "mydb":
con = sqlite.connect("mydb")
cur = con.cursor()
# we can also implement a custom text_factory ...
# here we implement one that will ignore Unicode characters that cannot be
# decoded from UTF-8
#con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
# by default, rows are returned as Unicode
# but we can make pysqlite always return bytestrings ...
con.text_factory = str
#con.text_factory = pysqlite2.dbapi2.OptimizedUnicode
now=date.today()
# 3 months ago
m3ago=date(now.year,now.month-3,1)
#fm="2007-06-14"
fm=m3ago.strftime("%Y.%m.%d")
#to="2007-06-15"
to=now.strftime("%Y.%m.%d")
print "최근3개월사용정보"
print "<br>"
print "<br>"
print "시작일: "+fm
print "~"
print "오늘 : "+to
print "<br>"
print "기간내 접수 기준 금액입니다."
print "<br><br>"
# Execute the SELECT statement:
cur.execute("select cardno,sum(price) from credituse where (usedate between ? and ?) and accept='접수' group by cardno",(fm,to))
# Retrieve all rows as a sequence and print that sequence:
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
m2ago=date(now.year,now.month-2,1)
nextm=date(now.year,now.month+1,1)
fm2=m2ago.strftime("%Y.%m.%d")
to2=nextm.strftime("%Y.%m.%d")
print "익월 첫날 예상"
print "<br>"
print "<br>"
print "시작일: "+fm2
print "~"
print "담달첫날 : "+to2
print "<br>"
print "기간내 접수 기준 금액입니다."
print "<br><br>"
# Execute the SELECT statement:
cur.execute("select cardno,sum(price) from credituse where (usedate between ? and ?) and accept='접수' group by cardno",(fm2,to2))
# Retrieve all rows as a sequence and print that sequence:
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
print "--참고--<br>"
print "<a href=mywayinfo.html target=_blank>"
print "V344:MY WAY</a><br>"
print "V353:OUTBACK<br>"
print "<a href='http://www.hanabank.com/online/contents/card/product/prod_02/prod_0206/prod_02063/index.jsp' target=_blank>"
print "V876:AUTO"
print "</a>"
print "<br>"
print "<br>상세내역<br>"
cur.execute("select * from credituse where usedate between ? and ? order by usedate",(fm,to))
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
print "<a href=index.html>처음으로가기</a>"
# -*- coding: cp949 -*-
import sys
sys.path.append('/opt/lib/python2.4/site-packages')
from pysqlite2 import dbapi2 as sqlite
from datetime import date
import csv, os, string,cgi
print "Content-Type: text/html"
# Create a connection to the database file "mydb":
con = sqlite.connect("mydb")
cur = con.cursor()
# we can also implement a custom text_factory ...
# here we implement one that will ignore Unicode characters that cannot be
# decoded from UTF-8
#con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
# by default, rows are returned as Unicode
# but we can make pysqlite always return bytestrings ...
con.text_factory = str
#con.text_factory = pysqlite2.dbapi2.OptimizedUnicode
now=date.today()
# 3 months ago
m3ago=date(now.year,now.month-3,1)
#fm="2007-06-14"
fm=m3ago.strftime("%Y.%m.%d")
#to="2007-06-15"
to=now.strftime("%Y.%m.%d")
print "최근3개월사용정보"
print "<br>"
print "<br>"
print "시작일: "+fm
print "~"
print "오늘 : "+to
print "<br>"
print "기간내 접수 기준 금액입니다."
print "<br><br>"
# Execute the SELECT statement:
cur.execute("select cardno,sum(price) from credituse where (usedate between ? and ?) and accept='접수' group by cardno",(fm,to))
# Retrieve all rows as a sequence and print that sequence:
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
m2ago=date(now.year,now.month-2,1)
nextm=date(now.year,now.month+1,1)
fm2=m2ago.strftime("%Y.%m.%d")
to2=nextm.strftime("%Y.%m.%d")
print "익월 첫날 예상"
print "<br>"
print "<br>"
print "시작일: "+fm2
print "~"
print "담달첫날 : "+to2
print "<br>"
print "기간내 접수 기준 금액입니다."
print "<br><br>"
# Execute the SELECT statement:
cur.execute("select cardno,sum(price) from credituse where (usedate between ? and ?) and accept='접수' group by cardno",(fm2,to2))
# Retrieve all rows as a sequence and print that sequence:
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
print "--참고--<br>"
print "<a href=mywayinfo.html target=_blank>"
print "V344:MY WAY</a><br>"
print "V353:OUTBACK<br>"
print "<a href='http://www.hanabank.com/online/contents/card/product/prod_02/prod_0206/prod_02063/index.jsp' target=_blank>"
print "V876:AUTO"
print "</a>"
print "<br>"
print "<br>상세내역<br>"
cur.execute("select * from credituse where usedate between ? and ? order by usedate",(fm,to))
for row in cur:
for col in row:
print col
print "<br>"
print "<br>"
print "<a href=index.html>처음으로가기</a>"