Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
761 B
2
Indexable
import mysql.connector

mydb = mysql.connector.connect(
host = "localhost",
user = "root",
password = "",
database = "facebook"
)


mycursor = mydb.cursor()

users = """CREATE TABLE users (
id INT (11),
name VARCHAR (100),
age INT (11),
gender VARCHAR (30),
nationality VARCHAR(30)
)"""

comments = """CREATE TABLE comments (
id INT (11),
text VARCHAR (200),
user_id INT (11),
post_id INT (11)
)"""

posts = """CREATE TABLE posts (
id INT(11),
title VARCHAR(100),
description VARCHAR (300),
user_id INT (11)
)"""

likes = """CREATE TABLE likes (
id INT (11),
user_id INT (11),
post_id INT (11)
)"""

mycursor.execute (users)
mycursor.execute (comments)
mycursor.execute (posts)
mycursor.execute (likes)
mydb.close()