2020-09-08 11:55:26 +02:00
|
|
|
"""
|
|
|
|
Insert value into addressbook
|
|
|
|
"""
|
|
|
|
|
2020-12-23 20:42:18 +01:00
|
|
|
from bmconfigparser import BMConfigParser
|
|
|
|
from helper_sql import sqlExecute, sqlQuery
|
2020-09-08 11:55:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
def insert(address, label):
|
|
|
|
"""perform insert into addressbook"""
|
2020-12-23 20:42:18 +01:00
|
|
|
queryreturn = sqlQuery(
|
|
|
|
'''SELECT count(*) FROM addressbook WHERE address=?''', address)
|
2020-09-08 11:55:26 +02:00
|
|
|
|
2020-12-23 20:42:18 +01:00
|
|
|
if address not in BMConfigParser().addresses() and not queryreturn[0][0]:
|
|
|
|
return sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', label, address) == 1
|
|
|
|
return False
|