Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- class Database:
- def __init__(self, db):
- self.conn = sqlite3.connect(db)
- self.cur = self.conn.cursor()
- self.cur.execute("CREATE TABLE IF NOT EXISTS tunes (id INTEGER PRIMARY KEY, rear real, arfront real, arrear real, springfront real, springrear real, rideheightfront real, rideheightrear real, reboundfront real, reboundrear real)")
- self.conn.commit()
- def fetch(self, id):
- self.cur.execute("SELECT * FROM tunes")
- items = self.cur.fetchall()
- return items
- def insert(self, rear, arfront, arrear, springfront, springrear, rideheightfront, rideheightrear, reboundfront, reboundrear):
- self.cur.execute("INSERT INTO tunes VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (rear, arfront, arrear, springfront, springrear, rideheightfront, rideheightrear, reboundfront, reboundrear))
- self.conn.commit()
- self.cur.execute("SELECT last_insert_rowid()")
- rowid = self.cur.fetchone()
- return rowid
- def remove(self, id):
- self.cur.execute("DELETE FROM tunes WHERE id=?", (id,))
- self.conn.commit()
- def __del__(self):
- self.conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement