This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE users ( | |
id INT PRIMARY KEY, | |
name VARCHAR(100) | |
); | |
CREATE TABLE posts ( | |
id INT PRIMARY KEY, | |
user_id INT, | |
content TEXT, | |
created_at DATETIME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE students ( | |
id INT PRIMARY KEY, | |
name VARCHAR(100), | |
age INT, | |
enrollment_year INT | |
); | |
CREATE TABLE enrollments ( | |
id INT PRIMARY KEY, | |
student_id INT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from typing import Optional | |
from django.db import connection | |
from concurrent.futures import TimeoutError, Future | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.INFO) | |
class QueryTimeoutException(BaseException): | |
def __init__(self, message: str, pid: Optional[int] = None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Thread | |
from multiprocessing import Process | |
def is_prime(number): | |
if number < 2: | |
return False | |
for x in range(2, number): | |
if number % x == 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Process | |
import time | |
import os | |
from concurrent.futures import ProcessPoolExecutor | |
def fib(number): | |
if number <= 1: | |
return number | |
return fib(number - 1) + fib(number - 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
import time | |
def fib(number): | |
if number <= 1: | |
return number | |
return fib(number - 1) + fib(number - 2) | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import requests | |
import time | |
def fetch_data(post_id): | |
url = f"https://jsonplaceholder.typicode.com/posts/{post_id}" | |
response = requests.get(url) | |
if response.status_code == 200: | |
print(f"Successfully fetched data for post {post_id}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Thread | |
def prepare_dough(): | |
print("Preparing the dough...") | |
time.sleep(3) | |
print("Dough is ready.") | |
def add_ingredients(): | |
print("Adding ingredients...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE employees ( | |
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, -- No necesario | |
first_name VARCHAR(50) NOT NULL, | |
last_name VARCHAR(50) NOT NULL, | |
email VARCHAR(100) NOT NULL UNIQUE, | |
hire_at DATE, -- No necesario | |
salary DECIMAL(10, 2) NOT NULL, | |
status ENUM('active', 'inactive') DEFAULT 'active', -- No necesario | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -- No necesario | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SCHEMA | |
DROP TABLE IF EXISTS project_employees; | |
DROP TABLE IF EXISTS projects; | |
DROP TABLE IF EXISTS employees; | |
CREATE TABLE IF NOT EXISTS employees ( | |
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, | |
first_name VARCHAR(100) NOT NULL, |
NewerOlder