2017 itrace startup in python
Python的第三方包依赖需要通过 pip 安装: 因此,我们在部署环境上需要先安装好pip,并安装第三方类库。Python2.x版本是没有自带pip 的:
$ wget https://bootstrap.pypa.io/get-pip.py
$ su - root # 切换到 root 用户
# python get-pip.py
运行:
$ pip install Flask
$ python section02.py
集成了 SQLAlchemy 包,是 Python 语言的一个 ORM 包,支持多种数据库。
$ pip install SQLAlchemy flask-sqlalchemy pymysql
$ python section02.py
section02.py
里面用到的是 cust表,其表结构和数据如下:
CREATE TABLE `cust` (
`cust_id` bigint(20) NOT NULL,
`area_id` int(11) DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`cust_group_id` bigint(20) DEFAULT NULL,
`cust_name` varchar(255) DEFAULT NULL,
`cust_number` varchar(255) DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
PRIMARY KEY (`cust_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into cust (cust_id, area_id, create_date, cust_group_id, cust_name, cust_number, update_date) values (1001, 200, "2017-09-04 19:59:29", 10010, "itsyc", "233", "2017-09-04 19:59:29");
insert into cust (cust_id, area_id, create_date, cust_group_id, cust_name, cust_number, update_date) values (1002, 200, "2017-09-04 19:59:29", 10011, "张三", "2233", "2017-09-04 19:59:29");