人口普查案例研究

Python 資料庫入門

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

人口普查案例研究

  • 準備 SQLAlchemy 與資料庫
  • 載入資料到資料庫
  • 以查詢解決資料科學問題
Python 資料庫入門

第 1 部分:準備 SQLAlchemy 與資料庫

  • 建立 engine 與 MetaData 物件
from sqlalchemy import create_engine, MetaData
engine = create_engine('sqlite:///census_nyc.sqlite')
metadata = MetaData()
Python 資料庫入門

第 1 部分:準備 SQLAlchemy 與資料庫

  • 建立並儲存 census 資料表
from sqlalchemy import (Table, Column, String, 
       Integer, Decimal, Boolean)

employees = Table('employees', metadata, Column('id', Integer()), Column('name', String(255)), Column('salary', Decimal()), Column('active', Boolean()))
metadata.create_all(engine)
Python 資料庫入門

一起來練習吧!

Python 資料庫入門

Preparing Video For Download...