Fixed bug in SQL for adding new subdomain

This commit is contained in:
rune 2023-03-28 11:41:06 +02:00
parent 7380175ba0
commit d271c44adf

View File

@ -124,6 +124,7 @@ def add_domian(domain):
def add_subdomain(domain): def add_subdomain(domain):
now = datetime.now().strftime("%Y-%m-%d %H:%M")
if set(domain).difference(ascii_letters + '.' + digits): if set(domain).difference(ascii_letters + '.' + digits):
print('[red]Error:[/red] Give the domain name in simple form e.g. [b]test.domain.com[/b]') print('[red]Error:[/red] Give the domain name in simple form e.g. [b]test.domain.com[/b]')
else: else:
@ -160,7 +161,7 @@ def add_subdomain(domain):
if response != 'Fail': if response != 'Fail':
response_data = response.json() response_data = response.json()
domainid = str(response_data['domain_record']['id']) domainid = str(response_data['domain_record']['id'])
cursor.execute('INSERT INTO subdomains values(?,?,?,?,?)',(domainid,topdomain_id,sub,ip,None,)) cursor.execute('INSERT INTO subdomains values(?,?,?,?,?,?,?)',(domainid,topdomain_id,sub,ip,None,now,now,))
conn.commit() conn.commit()
print('The domain %s has been added.' % (domain)) print('The domain %s has been added.' % (domain))
logging.info(time.strftime("%Y-%m-%d %H:%M") + ' - Info : subdomain %s added'%(domain)) logging.info(time.strftime("%Y-%m-%d %H:%M") + ' - Info : subdomain %s added'%(domain))