-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_setup.js
More file actions
31 lines (27 loc) · 812 Bytes
/
Copy pathdb_setup.js
File metadata and controls
31 lines (27 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var mysql= require('mysql');
var conn=mysql.createConnection({
host:'localhost',
user:'root',
port: '3306',
password:'',
multipleStatements: true
});
conn.connect((err)=>{
if(err){
console.log(err);
throw err;
}
else{
console.log("Connected!!");
}
});
sql="DROP DATABASE IF EXISTS xmeme;CREATE DATABASE IF NOT EXISTS xmeme;USE xmeme;CREATE TABLE IF NOT EXISTS `meme` (`ID` int(11) NOT NULL AUTO_INCREMENT,`NAME` varchar(10) NOT NULL,`CAPTION` varchar(100) NOT NULL,`URL` varchar(500) NOT NULL,PRIMARY KEY(`ID`),CONSTRAINT UK_Meme UNIQUE (`NAME`,`CAPTION`,`URL`));";
conn.query(sql,(err,result)=>{
if(err){
console.log(err);
}
else{
console.log('created the tables!!');
}
});
conn.end();