Day 27 Of 100DaysOfCode : Simple Code Using Database And SQL

iamdurga

Durga Pokharel

Posted on January 20, 2021

Day 27 Of 100DaysOfCode : Simple Code Using Database And SQL

This is my 27 day of #100DayOfCode and #python. Today I did some code on class inheritance with the help of goggle and textbook of coursera. Learned Database on python. In database on python I learned to make simple database table with the help of DB Browser.

Here is some database today I learned from coursera.

Simple Database And SQL

A database is a file that is organized for storing data. Most databases are organized like a dictionary in the sense that they map from keys to values. The biggest difference is that the database is on disk (or other permanent storage), so it persists after the program ends. Because a database is stored on permanent storage, it can store far more data than a dictionary, which is limited to the size of the memory in the computer.

import sqlite3

conn = sqlite3.connect("example.db")
Enter fullscreen mode Exit fullscreen mode

The code to create a database file and a table named Tracks with two columns in the database is given above. The connect operation makes a “connection” to the database stored in the file in the current directory.

c = conn.cursor()

#create table
c.execute("""CREATE TABLE Users 
(Name variable(128), sname, person)""")
Enter fullscreen mode Exit fullscreen mode

A cursor is like a file handle that we can use to perform operations on the data stored in the database. Calling cursor() is very similar conceptually to calling open() when dealing with text files. In above code we can create table name Users having the two column with name and person.


Day 27 of #100DaysOfcode and #Python
* More about class inheritance
* Learned about database on python
* Some simple SQL code#100DaysOfcode, #CodeNewbies ,#beginner pic.twitter.com/Lo3smgnDWm

— Durga Pokharel (@mathdurga) January 20, 2021
💖 💪 🙅 🚩
iamdurga
Durga Pokharel

Posted on January 20, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related