-
Notifications
You must be signed in to change notification settings - Fork 0
/
crp-notes-v0.1.py
150 lines (120 loc) · 3.28 KB
/
crp-notes-v0.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 8 22:35:46 2020
@author: toxic
"""
import sqlite3
import os
from prettytable import from_db_cursor
import clipboard
#lets clear everything
os.system('clear')
def newnote():
print('--------------------------')
heading = input("Heading:\n")
newnote = input("New NOTE:\n")
db=sqlite3.connect('noter')
qry="insert into notes (heading,note) values (?,?);"
try:
cur=db.cursor()
data_tuple= (heading,newnote)
cur.execute(qry, data_tuple)
db.commit()
print ("one record added successfully")
except:
print ("error in operation")
db.rollback()
db.close()
def editnote():
db=sqlite3.connect('noter')
sql="SELECT * from notes;"
cur=db.cursor()
cur.execute(sql)
x = from_db_cursor(cur)
print (x)
db.close()
print('--------------------------')
pick=input('Choose ID:')
int(pick)
db=sqlite3.connect('noter')
sql=("SELECT note from notes where id="+(pick))
#print(sql)
cur=db.cursor()
cur.execute(sql)
print('--------------------------')
#escape if pick is not found
myresult = cur.fetchall()
for x in myresult:
print(x[0])
#push var into OS clipboard
clipboard.copy(x[0])
print('-------------------------------------')
print('USE CTRL + V to access the note data.')
print('-------------------------------------')
editnote = input("EDIT NOTE:\n")
db=sqlite3.connect('noter')
qry=("update notes set note='"+editnote+"' where id="+pick+";")
try:
cur=db.cursor()
cur.execute(qry)
db.commit()
print ("one record updated successfully")
except:
print ("error in operation")
db.rollback()
db.close()
def deletenote():
print('----------DELETE----------------')
db=sqlite3.connect('noter')
sql="SELECT * from notes;"
cur=db.cursor()
cur.execute(sql)
x = from_db_cursor(cur)
print (x)
db.close()
pick=input('Choose ID:')
int(pick)
db=sqlite3.connect('noter')
sql=("DELETE FROM notes where id="+(pick))
print(sql)
cur=db.cursor()
cur.execute(sql)
print('--------------------------')
try:
db.commit()
print ("one record updated successfully")
except:
print ("error in operation")
db.rollback()
db.close()
def main():
pick = '99'
while pick != '0':
db=sqlite3.connect('noter')
sql="SELECT * from notes;"
cur=db.cursor()
cur.execute(sql)
x = from_db_cursor(cur)
print (x)
db.close()
print(' NEW NOTE: 1 || EDIT NOTE: 2 || DELETE NOTE: 3')
print('----------------------------------------------')
print('Press 0 to quit')
print('----------------------------------------------')
pick=input('Task? : ')
if pick == '1':
os.system('clear')
newnote()
os.system('clear')
if pick == '2':
os.system('clear')
editnote()
os.system('clear')
if pick == '3':
os.system('clear')
deletenote()
os.system('clear')
if pick == 0:
return
main()