SQLite3 Database With Python-Creating a Database, Table, and Running Queries

Опубликовано: 05 Октябрь 2024
на канале: Computer Science Information technology
70
1

purchase these products from amazon at cheap prices
Acer Swift 3 Thin & Light Laptop-https://amzn.to/3qbFKyf
Lenovo IdeaPad 3 Laptop-https://amzn.to/34LkfNh
cell phones and accessories-https://amzn.to/3tXgRYi
SanDisk 128GB microSDXC-Card-https://amzn.to/3icv12h
video editor monitors-https://amzn.to/3wbfQ1v
SAMSUNG Galaxy Buds Live True Wireless Earbuds -https://amzn.to/3th1Od1
________________________________________________________________________________
#SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the #SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.
To use the module, start by creating a Connection object that represents the database. Here the data will be stored in the example.db file:
import sqlite3
con = sqlite3.connect('example.db')
Once a Connection has been established, create a Cursor object and call its execute() method to perform SQL commands:
cur = con.cursor()

Create table
cur.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')

Insert a row of data
cur.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

Save (commit) the changes
con.commit()

We can also close the connection if we are done with it.
Just be sure any changes have been committed or they will be lost.
con.close()
_______________________________


#Code_With_Tuqi
Entire Videos-   / codewithtuqiprogramming  
Please Guys, like and subscribe to my channel!!