Advertisements
Advertisements
प्रश्न
Which method is used to connect a database? Give an example.
टीपा लिहा
Advertisements
उत्तर
- Connect()method is used to connect a database
- Connecting to a database means passing the name of the database to be accessed.
- If the database already exists the connection will open the same. Otherwise, Python will open a new database file with the specified name.
Example:
import sqlite3
# connecting to the database
connection = sqlite3.connect (“Academy.db”)
# cursor
cursor = connection. cursor()
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
