In [1]:
import sqlite3
In [2]:
conn = sqlite3.connect('db.sqlite3')
In [3]:
conn.execute('create table cars(id integer primary key, title text, ports text, year text)')
Out[3]:
In [4]:
conn.commit()
In [5]:
car = {'title': 'Gol 2011 completo', 'ports': '4 portas', 'year': '2010/2011'}
In [6]:
car
Out[6]:
In [8]:
conn.execute('insert into cars(title, ports, year) values (:title, :ports, :year)', car)
Out[8]:
In [9]:
conn.commit()
In [10]:
result = conn.execute('select title, ports, year from cars')
In [11]:
for car in result:
print(car)
In [12]:
result = conn.execute('select id, title, ports, year from cars')
In [13]:
for car in result:
print(car)
In [14]:
car = {'title': 'Gol 2011 completo', 'ports': '4 portas', 'year': '2010/2011'}
conn.execute('insert into cars(title, ports, year) values (:title, :ports, :year)', car)
Out[14]:
In [15]:
conn.commit()
In [16]:
result = conn.execute('select id, title, ports, year from cars')
In [17]:
for car in result:
print(car)
In [18]:
conn.close()
In [19]:
result = conn.execute('select id, title, ports, year from cars')
In [ ]: