Practical Programming
An Introduction to Computer Science
Using Python 3
(Pragmatic Programmers)
(Pragmatic Bookshelf)
Paul Gries (著)Jennifer Campbell (著)
Jason Montojo (著)Lynn Beighley (編集)
開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers)(Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 17(Databases)、17.10(Exercises) 2-g.を解いてみる。
17.10(Exercises) 2-g.
コード(BBEdit)
sample2_g.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sqlite3
connection = sqlite3.connect('census.db')
cur = connection.cursor()
cur.execute('SELECT MIN(population) FROM Capitals')
print(cur.fetchone()[0])
connection.commit()
connection.close()
入出力結果(Terminal, IPython)
$ ./sample2_g.py 5236 $
0 コメント:
コメントを投稿