開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 8(Data Has to Go Somewhere)、Things to Do 8.6.を解いてみる。
Things to Do 8.6.
コード(Eacs, BBEdit)
sample6.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sqlite3
connection = sqlite3.connect('books.db')
cur = connection.cursor()
cur.execute('''
CREATE TABLE books (title TEXT, author TEXT, year INT)
''')
print(connection, cur, sep='\n')
connection.commit()
cur.close()
connection.close()
入出力結果(Terminal, IPython)
$ ls books.db ls: books.db: No such file or directory $ ./sample6.py <sqlite3.Connection object at 0x10fa0be30> <sqlite3.Cursor object at 0x10fa8b7a0> $ ls books.db books.db $
0 コメント:
コメントを投稿