Onur

Özten

Bilgisayar Mühendisi & Yazılım Uzmanı


Python SQL Lite Sample

Create sql lite database, create table, add record to table, read records from table.

Create sql lite database, create table, add record to table, read records from table.

 

import sqlite3

con = sqlite3.connect("dersler.db")
cursor = con.cursor()

def tabloolustur():
    cursor.execute("CREATE TABLE ogrenciler (ad TEXT, soyad TEXT, numara INT, ogrencinotu INT)")

def degerekle():
    cursor.execute("INSERT INTO ogrenciler VALUES('Onur','ÖZTEN ÜĞİŞÖ',789512,76)")
    con.commit()


def degerlerial():
    """ değerleri alır """
    cursor.execute("select * from ogrenciler")

    data = cursor.fetchall()

    for i in data:
        print(i)

tabloolustur()
degerekle()
degerlerial()

con.close()