Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mysql=require('mysql');
- var conn=mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: 'rootpass',
- database: 'mydb'
- });
- conn.connect(function(err){
- if(err) throw err;
- console.log('Connected');
- });
- /*
- conn.query('CREATE DATABASE mydb', function(err, res){
- if(err) throw err;
- console.log(res);
- });
- */
- conn.query('CREATE TABLE IF NOT EXISTS elev\
- (ID INT,\
- nume VARCHAR(20),\
- prenume VARCHAR(20),\
- clasa INT,\
- nota_mate INT)',
- function(err, res){
- if(err) throw err;
- console.log(res);
- });
- /*
- conn.query('INSERT INTO elev(ID, nume, prenume, clasa, nota_mate)\
- VALUES(1, "Popescu", "Ion", 9, 4)',
- function(err, res){
- if(err) throw err;
- console.log(res);
- });
- */
- conn.query('SELECT * FROM elev', function(err, res){
- if(err) throw err;
- console.log(res);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement