SQL - Python - データとテーブル - あらゆるものにふさわしい場所 - null
Head First SQL ―頭とからだで覚えるSQLの基本、 Lynn Beighley(著)、 佐藤 直生(監訳)、 松永 多苗子(翻訳)、 オライリージャパンの 1章(データとテーブル - あらゆるものにふさわしい場所)、p.45(自分で考えてみよう)の解答を求めてみる。
schema5.sql
drop table my_contacts;
create table my_contacts(
last_name text not null,
first_name text not null,
email text not null,
gender text not null,
birthday date not null,
profession text not null,
location not null,
status text not null,
interests text not null,
seeking text not null
)
コード
sample5.py
#! /usr/bin/env python3
import sqlite3
con = sqlite3.connect('sample.db')
cur = con.cursor()
with open('schema5.sql') as f:
cur.executescript(f.read())
print(cur)
cur.close()
con.close()
入出力結果(Terminal, Zsh)
% ./sample5.py
<sqlite3.Cursor object at 0x1012bfcc0>
%