xxxxxxxxxx
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("CREATE DATABASE mydb", function (err, result) {
if (err) throw err;
console.log("Database created");
});
});
xxxxxxxxxx
# Writing to a file
with open('example.txt', 'w') as file:
file.write("Hello, world!")
# Reading from a file
with open('example.txt', 'r') as file:
content = file.read()
print(content)