How to fetch data from database in python?
SQL, Structured Query Language, was developed in the 1970s in an IBM laboratory. SQL is non-procedural and that is what makes it simple, it makes an RDBMS possible. SQL enables the following:
- Creating/ modifying a database’s structure.
- Changing security settings for system.
- Permitting users for working on database or tables.
- Querying database
- Inserting/ modifying/ deleting the database contents.
For fetching data from database we have to import sqlite3 library in python, and then we have to write the SQL command.
If we were connecting to MySQL, DB2, or some other database, we would import a different library, but all of them provide the same functions, so that the rest of our program does not have to change (at least, not much) if we switch from one database to another.
syntax:-
import sqlite3 query("write_the_querry") cursor.execute() ... ... ... connector.close()
This is how we can fetch data from database in python with the help of SQL.
Subscribe
Login
Please login to comment
0 Discussion