-
Notifications
You must be signed in to change notification settings - Fork 4
/
databaseOperationsPart6.py
34 lines (26 loc) · 1.16 KB
/
databaseOperationsPart6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
""" 28/12/2020 Database Connections
chinook.db dosyasını kendi dizinimize taşıdık ve üzerinden işlemler yapacağız.
select operasyonlarını function haline getirme ve insert operasyonları
"""
import sqlite3
def selectOperations():
connection = sqlite3.connect("chinook.db")
cursor = connection.execute("""Select FirstName,LastName
from Customers where firstName like '%s'
""")
for row in cursor:
print("First Name : "+row[0])
print("Last Name : "+row[1])
print('*****************')
connection.close()
def insertCustomer():
connection = sqlite3.connect('chinook.db')
cursor = connection.execute("""
insert into customers(FirstName,LastName,Email)
values('Melike','Eryılmaz','default@gmail.com')
""")
# veriyi insert etmek için commit() etmeliyiz..
connection.commit()
connection.close()
selectOperations()
insertCustomer()