// Import required modules
const express = require('express');
const mysql = require('mysql2');
const app = express();
const
connection=[Link]({
host:'localhost',
user:'root',
password:'12345678@N',
database:'student'
});
// Establish the connection
[Link]((err) => {
if (err) {
[Link]('Error connecting
to the database:', [Link]);
return;
}
[Link]('Connected to the database.');
});
//create database calledTeacher
const createDatabaseQuery = 'CREATE DATABASE IF NOT EXISTS Student';
[Link](createDatabaseQuery, (err) => {
if (err) {
[Link]('Error creating the database:', [Link]);
return;
}
[Link]('Database created (or already exists).');
});
const createTableQuery = `
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) not null
)
`;
[Link](createTableQuery, (err) => {
if (err) {
[Link]('Error creating the table:', [Link]);
return;
}
[Link]('Table created (or already exists).');
});