XML Files
XML (Extensible Markup Language) is a structured way of organizing data using human-readable tags. It works similarly to HTML, with opening tags, content, and closing tags.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
JSON (JavaScript Object Notation)
JSON is lightweight, easy to read, and widely used in REST APIs. It consists of key-value pairs and supports nested objects and arrays.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
CSV (Comma Separated Values)
CSV files have a row of headings followed by data rows, with each column separated by commas. They’re commonly used for database exports and spreadsheet data.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
YAML (YAML Ain’t Markup Language)
YAML is commonly used for configuration files and is similar to JSON but uses indentation instead of brackets. It’s space-sensitive like Python.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)
Databases
Databases are specialized programs for storing, organizing, and retrieving data at scale. They provide programmatic interfaces and handle data consistency automatically.
# Example MySQL connection
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="myuserrname",
passwd="mypassword"
)
cursor = db.cursor()
cursor.execute("SELECT * FROM mytable")
results = cursor.fetchall()
for result in results:
print(result)



