-



Download 9,79 Mb.
Pdf ko'rish
bet58/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   54   55   56   57   58   59   60   61   ...   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

NOT NULL
 to the end of the 
field when you create it. 


Challenges 139 - 145: SQLite 
1137 
 
 
 
Example Code 
 
import sqlite3 
This must be the first 
line of the program to 
allow Python to use 
the SQLite3 library. 
with sqlite3.connect(“company.db”) as db: 
 cursor=db.cursor() 
Connects to the company database. If no such database 
exists, it will create one. The file will be stored in the same 
folder as the program. 
cursor.execute(“““CREATE TABLE IF NOT EXISTS employees( 
 id integer PRIMARY KEY
 name text NOT NULL
 dept text NOT NULL, 
 salary integer);”””) 
Creates a table called employees which has four fields (id, name, dept and salary). It 
specifies the data type for each field, defines which field is the primary key and which 
fields cannot be left blank. The triple speech marks allow the code to be split over 
several lines to make it easier to read rather than having it all displayed in one line. 

Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   54   55   56   57   58   59   60   61   ...   64




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish