🔅 Advanced Python: Working with Databases
🌐 Author: Kathryn Hodge
🔰 Level: Advanced
⏰ Duration: 2h 6m
🌀
📗 Topics: Databases, Python
📤 Join @python_trainings for more courses
🌐 Author: Kathryn Hodge
🔰 Level: Advanced
⏰ Duration: 2h 6m
🌀
Explore the database options for powering your Python apps. Learn how to create and connect to different types of databases, including SQLite, MySQL, and PostgreSQL.
📗 Topics: Databases, Python
📤 Join @python_trainings for more courses
👍12🔥2👎1
🔸 Full description 🔸
To create functional and useful Python applications, you need a database. Databases allow you to store data from user sessions, track inventory, make recommendations, and more. However, Python is compatible with many options: SQLite, MySQL, and PostgreSQL, among others. Selecting the right database is a skill that advanced developers are expected to master. This course provides an excellent primer, comparing the different types of databases that can be connected through the Python Database API. Instructor Kathryn Hodge teaches the differences between SQLite, MySQL, and PostgreSQL and shows how to use the ORM tool SQLAlchemy to query a database. The final chapters put your knowledge to practical use in two hands-on projects: developing a full-stack application with Python, PostgreSQL, and Flask and creating a data analysis app with pandas and Jupyter Notebook. By the end, you should feel comfortable creating and using databases and be able to decide which Python database is right for you.
To create functional and useful Python applications, you need a database. Databases allow you to store data from user sessions, track inventory, make recommendations, and more. However, Python is compatible with many options: SQLite, MySQL, and PostgreSQL, among others. Selecting the right database is a skill that advanced developers are expected to master. This course provides an excellent primer, comparing the different types of databases that can be connected through the Python Database API. Instructor Kathryn Hodge teaches the differences between SQLite, MySQL, and PostgreSQL and shows how to use the ORM tool SQLAlchemy to query a database. The final chapters put your knowledge to practical use in two hands-on projects: developing a full-stack application with Python, PostgreSQL, and Flask and creating a data analysis app with pandas and Jupyter Notebook. By the end, you should feel comfortable creating and using databases and be able to decide which Python database is right for you.
👍21❤5🔥2👎1
🔅 Low Battery Notification
pip install psutil
import psutil
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = battery.percent
if percent <= 30 and plugged!=True:
# pip install py-notifier
# pip install win10toast
from pynotifier import Notification
Notification(
title="Battery Low",
description=str(percent) + "% Battery remain!!",
duration=5, # Duration in seconds
).send()
👍83❤46🔥16👎12
🔅 Countdown timer
import time
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(mins,secs)
print(timer, end="\r")
time.sleep(1)
t -= 1
print('Timer completed!')
t = input('Enter the time in seconds: ')
countdown(int(t))
🔥36👍29❤19👎11
🔅 Convert JPG to PNG
🔅 Convert PNG to JPG
from PIL import Image
im = Image.open("naruto.jpg").convert("RGB")
im.save("naruto.png", "png")
🔅 Convert PNG to JPG
from PIL import Image
im = Image.open("naruto.png").convert("RGB")
im.save("naruto.jpg", "jpeg")
pip install PIL
👍38❤9🔥5
🖥 Turn (almost) any Python command line program into a full GUI application with one line.
🔗 GitHub: https://github.com/chriskiehl/Gooey
https://t.me/LearnPython3
More Likes, Share, Subscribe 😉
🔗 GitHub: https://github.com/chriskiehl/Gooey
https://t.me/LearnPython3
More Likes, Share, Subscribe 😉
🔥30👍22❤9
🔅 Scan for open ports
from socket import *
import time
startTime = time.time()
if __name__ == '__main__':
target = input('Enter the host to be scanned: ')
t_IP = gethostbyname(target)
print ('Starting scan on host: ', t_IP)
for i in range(1, 10000):
s = socket(AF_INET, SOCK_STREAM)
conn = s.connect_ex((t_IP, i))
if(conn == 0) :
print ('Port %d: OPEN' % (i,))
s.close()
print('Time taken:', time.time() - startTime)
🔥23👍17❤12😁1
🔅 Compress Images
from PIL import Image
# https://t.me/LearnPython3
in_img = 'input.png'
out_img = 'compressed.png'
# Open the image
with Image.open(in_img) as img:
# Save the compressed image
img.save(out_img, 'PNG', quality=80)
print(f"Image compressed successfully!")
❤24👍12🔥8
🔅 Extract the colors and their codes from an image
from PIL import Image
from collections import Counter
# https://t.me/LearnPython3
# Open the image
image = Image.open('input.png')
# Convert the image to a list of RGB tuples
pixels = list(image.getdata())
# Use Counter to count the occurrences of each color
color_counts = Counter(pixels)
# Get the 6 most common colors
top_colors = color_counts.most_common(6)
# Print the extracted colors and their counts
for i, (color, count) in enumerate(top_colors):
color_block = "\033[48;2;{};{};{}m \033[0m".format(color[0], color[1], color[2])
print(f"Color {i + 1}: {color_block} RGB: {color} - Count: {count}")
👍27❤10🔥10👏1
🔅 Merge PDFs
@LearnPython3
pip install PyPDF2
from PyPDF2 import PdfFileMerger
# https://t.me/LearnPython3
# By appending in the end
def by_appending():
merger = PdfFileMerger()
# Either provide file stream
f1 = open("samplePdf1.pdf", "rb")
merger.append(f1)
# Or direct file path
merger.append("samplePdf2.pdf")
merger.write("mergedPdf.pdf")
# By inserting at after an specified page no.
def by_inserting():
merger = PdfFileMerger()
merger.append("samplePdf1.pdf")
merger.merge(0, "samplePdf2.pdf")
merger.write("mergedPdf1.pdf")
if __name__ == "__main__":
by_appending()
by_inserting()
@LearnPython3
👍39❤17🔥5👎2