コード例 #1
0
    def get_all_data(self):
        sql = ''' 
			SELECT * 
			FROM urls 
		'''
        db = SqliteCon()
        data = db.fetchall(sql)
        return data
コード例 #2
0
    def init_db(self):
        sql = """CREATE TABLE IF NOT EXISTS 'urls' (
			'id'	INTEGER PRIMARY KEY AUTOINCREMENT,
			'url'	TEXT,
			'status'	INTEGER,
			'status_label' TEXT,
			'is_checked'	INTEGER
		)"""
        db = SqliteCon()
        db.execute(sql)
コード例 #3
0
 def search(self, to_search, factor):
     sql = "SELECT * FROM urls "
     params = ()
     if to_search != "":
         if factor.lower() == "url":
             sql = sql + "WHERE url LIKE ? "
             params = (to_search + '%', )
         elif factor.lower() == "status":
             sql = sql + "WHERE status LIKE ? "
             params = (to_search + '%', )
         else:
             sql = sql + "WHERE url LIKE ? OR status LIKE ? "
             params = (to_search + '%', to_search + '%')
     db = SqliteCon()
     return db.fetchall(sql, params)
コード例 #4
0
 def delete_url(self, url_id):
     sql = "DELETE FROM urls WHERE id = ?"
     params = (url_id, )
     db = SqliteCon()
     db.delete(sql, params)
コード例 #5
0
 def get_checked_urls(self):
     sql = "SELECT * FROM urls WHERE is_checked = ?"
     params = (1, )
     db = SqliteCon()
     return db.fetchall(sql, params)
コード例 #6
0
 def update_url(self, url_obj):
     sql = "UPDATE urls SET url = ?, is_checked = ?, status = ? , status_label = ? WHERE id = ?"
     params = (url_obj.url, url_obj.is_checked, url_obj.status.value,
               self.get_status_label(url_obj.status), url_obj.id)
     con = SqliteCon()
     con.update(sql, params)
コード例 #7
0
 def insert_url(self, url_obj):
     sql = "INSERT INTO urls(url, status, status_label, is_checked) VALUES(?, ?, ?, ?)"
     params = (url_obj.url, url_obj.status.value,
               self.get_status_label(url_obj.status), url_obj.is_checked)
     con = SqliteCon()
     return con.insert(sql, params)