Last active
June 5, 2018 00:56
-
-
Save BlogBlocks/d6528c2fe1ebcd7132b5a020debb9e26 to your computer and use it in GitHub Desktop.
An easy to use memory program create this file in you home directory. Give it proper execute permission with chmod +x. Create a sym-link to it in one of your bin directories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import sys | |
import sqlite3 | |
conn = sqlite3.connect("WHATZUP.db") | |
c = conn.cursor() | |
if len(sys.argv) < 3: | |
print "\n*****************************************" | |
print "Not enough options were passed." | |
print "WHATZUP requires 2 arguments. the first -H , -R , -I , -D or -S .\nThe second can be a period." | |
print "If wanting to read all entries use -R . (use the period)" | |
print "even use the period with help. -H . must be entered." | |
print "*****************************************\n" | |
sys.exit() | |
mod = sys.argv[1] | |
def create(database,conn=conn, c=c): | |
c.execute("CREATE VIRTUAL TABLE PROJECT using FTS4 (input)") | |
conn.commit() | |
text = "Database Created" | |
return text | |
def insert(data,conn=conn, c=c): | |
c.execute("INSERT into PROJECT values (?)", (data,)) | |
for row in c.execute("SELECT ROWID,* FROM PROJECT ORDER BY ROWID DESC LIMIT 1"): | |
print "\nPOST VERIFIED:\n",row[0],row[1] | |
conn.commit() | |
conn.close() | |
return data | |
def search(data,conn=conn, c=c): | |
for row in c.execute("SELECT ROWID,* FROM PROJECT WHERE input MATCH ?",(data,)): | |
print "\nPOST VERIFIED:\n",row[0],row[1] | |
conn.commit() | |
conn.close() | |
return data | |
def delete(rowid,conn=conn, c=c): | |
c.execute("DELETE FROM PROJECT WHERE rowid = ?", (rowid,)) | |
conn.commit() | |
conn.close() | |
text = "ROWID "+rowid+" Deleted" | |
return text | |
def main(): | |
conn = sqlite3.connect("/home/jack/hubiC/Databases/PROJECT.db") | |
c = conn.cursor() | |
for row in c.execute("SELECT rowid, * FROM PROJECT"): | |
print row[0],": ",row[1] | |
def HELP(): | |
TXT = """ | |
USE: WHATZUP argv[1] argv[2] | |
argv[1] sets the mod: | |
-I insert / -D delete / -R read / -H help | |
examples: | |
Notice the entry is in parenthese. | |
-I to insert "STUFF to be inserted" | |
WHATZUP -I "STUFF to be inserted" | |
-D to delete where rowid is 3 | |
WHATZUP -D 3 | |
Notice the period after -R . | |
-R . read all | |
To search for the term "current project" | |
WHATZUP -S 3 | |
-S "current project" | |
WHATZUP -R . | |
-H help on options | |
WHATZUP -H . | |
""" | |
print TXT | |
if mod == "-H" or mod == "h": | |
HELP() | |
if mod == "-R": | |
main() | |
if mod == "-I": | |
data = sys.argv[2] | |
insert(data) | |
if mod == "-D": | |
rowid = sys.argv[2] | |
delete(rowid) | |
if mod == "-S": | |
data = sys.argv[2] | |
search(data) | |
else: | |
print "_________________\n" | |
print "Command Completed" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use it once the symlink is created is very easy. it stores
Just enter in the terminal:
This is to enter data:
jack@jack-desktop:~/Desktop$ WHATZUP -I "This program can be used like a
POST VERIFIED:
19 This program can be used like a
memory. I use it to remember project directories, snippets, dates
anything I want to easily look up
This is to read all entries:
WHATZUP -R .