DevOps Classroom notes 22/Oct/2025

Dealing with json and yaml files

  • For json we have a standard libarary module json
  • For yaml we need to use a pypi package pyyaml
uv add pyyaml

Databases

  • Databases handle storing and retreival of data.
  • Databases are of different types, on a larger note
    • Relational Databases
    • NOSQL Databases
  • Relational Databases use a Standard called as SQL to manage the data and the companies that use this Standard and built database management systems
    • Microsoft SQL Server
    • Oracle
    • mysql
    • postgres
    • db2
    • sqlite
  • Relational databases use Tables which can have relationships between them

Designing tables

  • Problem: Students joining courses
  • SQL:
    • Create
    • Retrieve
    • Update
    • Delete
  • Create Tables
Database SQL Syntax
MySQL sql CREATE TABLE student ( sno INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, phone VARCHAR(15), email VARCHAR(100) UNIQUE );
PostgreSQL sql CREATE TABLE student ( sno SERIAL PRIMARY KEY, name VARCHAR(100) NOT NULL, phone VARCHAR(15), email VARCHAR(100) UNIQUE );
SQLite sql CREATE TABLE student ( sno INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, phone TEXT, email TEXT UNIQUE );
SQL Server sql CREATE TABLE student ( sno INT IDENTITY(1,1) PRIMARY KEY, name NVARCHAR(100) NOT NULL, phone NVARCHAR(15), email NVARCHAR(100) UNIQUE );
Oracle sql CREATE TABLE student ( sno NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name VARCHAR2(100) NOT NULL, phone VARCHAR2(15), email VARCHAR2(100) UNIQUE );
  • Insert records
Database SQL Syntax
MySQL sql INSERT INTO student (name, phone, email) VALUES ('Tony Stark', '9998887776', 'tony@starkindustries.com'), ('Steve Rogers', '9991112223', 'steve@avengers.com'), ('Natasha Romanoff', '8885554442', 'natasha@shield.org');
PostgreSQL sql INSERT INTO student (name, phone, email) VALUES ('Tony Stark', '9998887776', 'tony@starkindustries.com'), ('Steve Rogers', '9991112223', 'steve@avengers.com'), ('Natasha Romanoff', '8885554442', 'natasha@shield.org');
SQLite sql INSERT INTO student (name, phone, email) VALUES ('Tony Stark', '9998887776', 'tony@starkindustries.com'); INSERT INTO student (name, phone, email) VALUES ('Steve Rogers', '9991112223', 'steve@avengers.com'); INSERT INTO student (name, phone, email) VALUES ('Natasha Romanoff', '8885554442', 'natasha@shield.org');
SQL Server sql INSERT INTO student (name, phone, email) VALUES ('Tony Stark', '9998887776', 'tony@starkindustries.com'), ('Steve Rogers', '9991112223', 'steve@avengers.com'), ('Natasha Romanoff', '8885554442', 'natasha@shield.org');
Oracle sql INSERT INTO student (name, phone, email) VALUES ('Tony Stark', '9998887776', 'tony@starkindustries.com'); INSERT INTO student (name, phone, email) VALUES ('Steve Rogers', '9991112223', 'steve@avengers.com'); INSERT INTO student (name, phone, email) VALUES ('Natasha Romanoff', '8885554442', 'natasha@shield.org'); COMMIT;
  • In modern day programming we prefer ORMs (Object Relational Mapping) where we interact with Objects rather than tables & ORM frameworks deal with different databases with same code written. Popular ORM Frameworks
    • Java -> Hibernate
    • C# -> Entity Framework
    • Python -> SQL Alchemy, Django-ORM

Errors & Exception Handling

  • Both Errors and Exceptions are deviations from ideal behavior, whereas Errors cannot be handled by program & Exceptions can be
  • In python we have a hierarchy of Exceptions
BaseException
├─ SystemExit
├─ KeyboardInterrupt
├─ GeneratorExit
└─ Exception
   ├─ ArithmeticError
   │  ├─ FloatingPointError
   │  ├─ OverflowError
   │  └─ ZeroDivisionError
   ├─ AssertionError
   ├─ AttributeError
   ├─ BufferError
   ├─ EOFError
   ├─ ImportError
   │  └─ ModuleNotFoundError
   ├─ LookupError
   │  ├─ IndexError
   │  └─ KeyError
   ├─ MemoryError
   ├─ NameError
   │  └─ UnboundLocalError
   ├─ OSError
   │  ├─ BlockingIOError
   │  ├─ ChildProcessError
   │  ├─ ConnectionError
   │  │  ├─ BrokenPipeError
   │  │  ├─ ConnectionAbortedError
   │  │  ├─ ConnectionRefusedError
   │  │  └─ ConnectionResetError
   │  ├─ FileExistsError
   │  ├─ FileNotFoundError
   │  ├─ InterruptedError
   │  ├─ IsADirectoryError
   │  ├─ NotADirectoryError
   │  ├─ PermissionError
   │  ├─ ProcessLookupError
   │  └─ TimeoutError
   ├─ ReferenceError
   ├─ RuntimeError
   │  ├─ NotImplementedError
   │  └─ RecursionError
   ├─ StopAsyncIteration
   ├─ StopIteration
   ├─ SyntaxError
   │  └─ IndentationError
   │     └─ TabError
   ├─ SystemError
   ├─ TypeError
   ├─ ValueError
   │  └─ UnicodeError
   │     ├─ UnicodeDecodeError
   │     ├─ UnicodeEncodeError
   │     └─ UnicodeTranslateError
   └─ Warning
      ├─ DeprecationWarning
      ├─ PendingDeprecationWarning
      ├─ RuntimeWarning
      ├─ SyntaxWarning
      ├─ UserWarning
      ├─ FutureWarning
      ├─ ImportWarning
      ├─ UnicodeWarning
      ├─ BytesWarning
      ├─ ResourceWarning
      └─ EncodingWarning

  • Lets write a simple divide function
def divide(a:int, b:int) -> float:
    return a/b
  • Now lets call this function with b as 0
divide(4,0)

  • We can handle errors by try, except, finally blocks
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%