2015-11-01 14:04:41 -06:00
|
|
|
#!/usr/bin/python3
|
2015-11-01 14:08:45 -06:00
|
|
|
#
|
|
|
|
# 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/>.
|
2015-11-01 14:04:41 -06:00
|
|
|
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
# Main starts here
|
|
|
|
# ----------------
|
2015-11-01 14:08:45 -06:00
|
|
|
# Create a connection
|
|
|
|
conn = sqlite3.connect('bookmarks.db')
|
2015-11-01 14:04:41 -06:00
|
|
|
c = conn.cursor()
|
|
|
|
|
2015-11-01 14:08:45 -06:00
|
|
|
# Create table if it doesn't exist
|
2015-11-04 06:47:05 -06:00
|
|
|
c.execute('''DROP TABLE if exists bookmarks''')
|
2015-11-01 14:08:45 -06:00
|
|
|
c.execute('''CREATE TABLE if not exists bookmarks
|
2015-11-04 06:47:05 -06:00
|
|
|
(id integer PRIMARY KEY AUTOINCREMENT, URL text NOT NULL UNIQUE, tags text, metadata text)''')
|
2015-11-01 14:04:41 -06:00
|
|
|
|
2015-11-01 14:08:45 -06:00
|
|
|
# Insert values
|
2015-11-04 06:47:05 -06:00
|
|
|
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','')")
|
2015-11-01 14:04:41 -06:00
|
|
|
conn.commit()
|
|
|
|
|
2015-11-01 14:08:45 -06:00
|
|
|
# Search the table
|
2015-11-01 14:04:41 -06:00
|
|
|
t = ('search',)
|
2015-11-04 06:47:05 -06:00
|
|
|
for row in c.execute("SELECT * FROM bookmarks WHERE tags LIKE ('%' || ? || '%')", t):
|
2015-11-01 14:04:41 -06:00
|
|
|
print(row)
|
|
|
|
|
|
|
|
conn.close()
|