buku/markit

44 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python3
#
# Bookmark management utility
#
# Copyright (C) 2015 Arun Prakash Jana <engineerarun@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with markit. If not, see <http://www.gnu.org/licenses/>.
import sqlite3
# Main starts here
# ----------------
# Create a connection
conn = sqlite3.connect('bookmarks.db')
c = conn.cursor()
# Create table if it doesn't exist
c.execute('''DROP TABLE if exists bookmarks''')
c.execute('''CREATE TABLE if not exists bookmarks
(id integer PRIMARY KEY AUTOINCREMENT, URL text NOT NULL UNIQUE, tags text, metadata text)''')
# Insert values
c.execute("INSERT INTO bookmarks(URL, tags, metadata) VALUES ('www.google.com','search engine','')")
c.execute("INSERT INTO bookmarks(URL, tags, metadata) VALUES ('http://www.google.com/','search engine','')")
conn.commit()
# Search the table
t = ('search',)
for row in c.execute("SELECT * FROM bookmarks WHERE tags LIKE ('%' || ? || '%')", t):
print(row)
conn.close()