DEV Community

Durga Pokharel
Durga Pokharel

Posted on

2

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

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (1)

Collapse
 
otumianempire profile image
Michael Otu

Download sqlite-browser to help you manage the data easily.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay