-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepository.py
More file actions
27 lines (23 loc) · 1.12 KB
/
repository.py
File metadata and controls
27 lines (23 loc) · 1.12 KB
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
# -*- coding: utf-8 -*-
import sqlite3 as db
def create_base():
with db.connect('db.sqlite3') as connection:
cursor = connection.cursor()
cursor.executescript("""CREATE TABLE IF NOT EXISTS parts (
id serial PRIMARY KEY,
part_type character varying(100),
mark character varying(100),
model character varying(100),
frame character varying(50),
engine character varying(50),
year character varying(4),
price double precision,
company character varying(100),
photo character varying(100))""")
def add(parts):
with db.connect('db.sqlite3') as connect:
cursor = connect.cursor()
cursor.executemany("""INSERT INTO parts(part_type, mark, model, frame, engine, year, price, company, photo)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)""",
parts)
connect.commit()