Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

UCAS Database Lab2

目录结构

目录 用途
data 处理后的数据
php php文件
report 实验报告
sql sql语句
train-2016-10 原始数据
data_generate.py 数据生成
data_process.py 数据处理

创建数据库

使用77qiqi/ucas-dbms-hw-2020 (docker.com)提供的docker,在镜像中安装postgresql并启动,执行以下命令:

$ sudo apt-get install postgresql
$ sudo service postgresql start

执行psql进入数据库并创建一个名为lab2的数据库

$ psql
dbms=# create database lab2;
CREATE DATABASE
dbms=# \q

进入lab2数据库

psql -d lab2

创建名为postgres的用户,执行以下命令:

ALTER USER postgres WITH PASSWORD 'dbms';

退出数据库,编辑目录下的文件:/etc/postgresql/10/main/pg_hba.conf,添加如下内容:

      -> # TYPE  DATABASE        USER            ADDRESS                 METHOD
      -> local   all             postgres                                    md5

若文件中有如下内容,即存在名为postgres的管理员名,修改postgres为其他名字:

image

进入数据库

$ psql -d lab2 -U postgres

拷贝sql/create_table.sql中的内容执行,创建数据库。

将数据文件拷贝进入镜像,拷贝数据进入数据库

copy train from 'data/train.csv' with (format csv, delimiter ',');
copy users from 'data/users.csv' with (format csv, delimiter ',');
copy stationlist from 'data/stationlist.csv' with (format csv, delimiter ',');
copy passstation from 'data/passstation.csv' with (format csv, delimiter ',');
copy sectioninfo from 'data/sectioninfo.csv' with (format csv, delimiter ',');
copy sectionticket from 'data/sectionticket.csv' with (format csv, delimiter ',');

重启postgresql,使用命令 sudo service postgresql restart

启动apache2,使用命令sudo service apache2 start

访问网页

将所有网页文件拷贝进入镜像的/var/www/html中

可以通过访问http://localhost:8080/welcome.php进入主页,体验使用。

Comments ( 0 )

Sign in for post a comment

About

A train booking database system for UCAS database course lab. spread retract
PHP and 3 more languages
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more