20.python Database Programming (PostgreSQL)
20.python Database Programming (PostgreSQL)
# create a cursor
cur = conn.cursor()
# create table
# data_list=[('user2','user2',19,"F",10000),('user3','user3',19,"F",10000),('user4','use
# for i in data_list:
# print(i)
# sql=f"""insert into employee values('{i[0]}','{i[1]}',{i[2]},'{i[3]}',{i[4]})"""
# print(sql)
# cur.execute(sql)
# insert data
cur.execute(sql)
conn.commit()
conn.close()
(1, '2017 Ferrari 488 GTB', 'CA', 'Norwood', 'White', '488 GTB', 2017,
'used', 40000, '<p>The <strong>Ferrari 488</strong> (Type F14
2M) is a <a href="https://en.wikipedia.org/wiki/Rear_mid-engine,_r
ear-wheel_drive_layout" title="Rear mid-engine, rear-wheel drive layou
t">mid-engine</a> <a href="https://en.wikipedia.org/wiki/Sports_ca
r" title="Sports car">sports car</a> produced by the Italian autom
obile manufacturer <a href="https://en.wikipedia.org/wiki/Ferrari"
title="Ferrari">Ferrari</a>. The car replaced the <a href="http
s://en.wikipedia.org/wiki/Ferrari_458" title="Ferrari 458">458</a>, bei
ng the first mid-engine Ferrari to use a turbocharged V8 since the&nbs
p;<a href="https://en.wikipedia.org/wiki/Ferrari_F40" title="Ferrari F4
0">F40</a>.</p>\r\n\r\n<p>The car is powered by a 3.9-litre <a hre
f="https://en.wikipedia.org/wiki/Twin-turbocharged" title="Twin-turboch
arged">twin-turbocharged</a> <a href="https://en.wikipedia.org/wik
i/V8_engine" title="V8 engine">V8 engine</a>, smaller in displacement b
ut generating a higher power output than the 458's <a href="ht
tps://en.wikipedia.org/wiki/Naturally_aspirated_engine" title="Naturall
y aspirated engine">naturally aspirated engine</a>. The 488 GTB was nam
ed "The Supercar of the Year 2015" by car magazine <a hr
ef="https://en.wikipedia.org/wiki/Top_Gear_(magazine)" title="Top Gear
(magazine)"><em>Top Gear</em></a>, as well as becoming <em><a href
="https://en.wikipedia.org/wiki/Motor_Trend" title="Motor Trend">Motor
Trend</a></em>'s 2017 "Best Driver's Car".<a href="ht
tps://en.wikipedia.org/wiki/Ferrari_488#cite_note-7">[7]</a> <a hr
ef="https://en.wikipedia.org/wiki/Jeremy_Clarkson" title="Jeremy Clarks
on">Jeremy Clarkson</a> announced the 488 Pista as his 2019 Superc
ar of the Year.<a href="https://en.wikipedia.org/wiki/Ferrari_488#cite_
note-8">[8]</a> The 488 was succeeded by the <a href="http
s://en.wikipedia.org/wiki/Ferrari_F8_Tributo" title="Ferrari F8 Tribut
o">F8 Tributo</a> in February 2019</p>', 'photos/2022/01/19/190253
6891.jpg', 'photos/2022/01/19/1902537043.jpg', 'photos/2022/01/19/19025
37077.jpg', 'photos/2022/01/19/1902537082.jpg', 'photos/2022/01/19/1902
536917.jpg', 'Airbags,Air Conditioning,Alarm System,ParkAssist,Auto Sta
rt/Stop', 'Sport', '3.9-litre twin-turbocharged V8 engine', 'Automati
c', 'Grey', 10000, '3', 2, 'WET75', 5, 'Petrol', '1', True, datetime.da
tetime(2022, 1, 19, 19, 36, 1, 366174, tzinfo=datetime.timezone(datetim
e.timedelta(seconds=19800))))
In [ ]: