Group 3
Group 3
Programming Languages
Introduction
• • What is a Database?
• - A structured collection of data stored electronically.
• • Importance of Databases in Applications:
• - Centralized data storage, retrieval, and
management.
• - Backbone of many software applications.
• • What is Database Access?
• - The process of connecting a programming language
to a database.
Programming Languages and Databases
• • Common Programming Languages:
• - Python, Java, C#, PHP, Ruby, etc.
• • Types of Databases:
• - Relational Databases (e.g., MySQL,
PostgreSQL, Oracle).
• - NoSQL Databases (e.g., MongoDB,
Cassandra).
Key components to consider
• Database management system
• Database library/drivers. Enables
communication between the program and
dbms
• Connecton parameters i.e Host,
Port,Username and database name
Steps for Database Access
1. Choose the database. Decide the type of
database i.e relational (SQL)e.g MySQL,
PostgreSQL and etc or non-relational like
MongoDB,firebase and etc
2. Install Database Drivers
Necessary to connect a programming language
with the database.
Steps for Database Access
3. Establish a Connection
Use the drivers /library to establish a connection
4.Execute Queries
SQL commands for data manipulation (SELECT, INSERT,
UPDATE, DELETE).
5. Handle Results
process and display retrieved data.
7.Close the Connection
8. Free up resources and ensure security.
Tools and Libraries
• • Python:
• - Libraries: SQLite, SQLAlchemy, psycopg2
(PostgreSQL), PyODBC (SQL Server).
• • Java:
• - Libraries: JDBC (Java Database
Connectivity).
• • C#:
• - Libraries: ADO.NET, Entity Framework.
Example Code Snippet
• Python Example (Connecting to SQLite):
• import sqlite3
• # Connect to database
• connection = sqlite3.connect('example.db')
• # Create a cursor
• cursor = connection.cursor()
• # Execute a query
• cursor.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)")