dBase for my website always gives me this error Invalid syntax

0 votes

I have a web page I have developed and now am stuck getting told that the syntax is wrong. I cannot find the error, can someone please help me find my error? Here is my code for the database that is giving me my error:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import Select
from bs4 import BeautifulSoup 
from models import *

import os # File I/O
import time
import shutil
import glob
import configparser
config_parser = configparser.ConfigParser()
config_parser.read("config.ini")

pdownload_dir = os.path.abspath('./prism_downloads/')
dt = str(datetime.datetime.now())
filelist = glob.glob(download_dir + '/*.html')
dbpath = ('./db')
def db_Prism():

        database.connect()
        database.create_tables([Prism], safe=False)
        database.close()

        for root, dir, files in os.walk(pdownload_dir):
            for file in files:
                print(file)
                file_markup = ''
                with open(os.path.abspath(os.path.join(pdownload_dir, file)), 'r') as html:
                    file_markup = html.read()
                if file_markup == '':
                    print('ERROR: File was not read')
                print('Reading {0} into BS4'.format(file))
                soup = BeautifulSoup(file_markup, 'html.parser')
                print('File parsed')
                data = []
                table = soup.find('table')
                rows = table.find_all('tr') # 18th row is header row 
                cols = rows[0].find_all('td')
                cols = [ele.text.strip() for ele in cols] 
                database.connect()
                for row in rows[0:]:
                    d = row.find_all('td')
                    d = [ele.text.strip() for ele in d]
                    data.append([ele for ele in d if ele]) # Get rid of empty values 
                    Prism.create(pmt_id=(d[1]),
                        old_status=d[3],
                        new_status=(d[4]),
                        last_updated=float(d[5])    
Line 96                 database.close()


Now here is the error message from my console:

C:\Users\Documents\NetBeansProjects\BudgetHome>python prism.py
  File "prism.py", line 96
    database.close()
           ^
SyntaxError: invalid syntax

C:\Users\Documents\NetBeansProjects\BudgetHome>

Help please :(

Mar 30, 2018 in Selenium by Shubham
• 13,490 points
1,194 views

1 answer to this question.

0 votes
Seems like you are missing a close parenthesis at the end of line 95. And you should also outdent line 96 two levels (even with the database.connect() statement).
answered Mar 30, 2018 by nsv999
• 5,500 points

Related Questions In Selenium

0 votes
1 answer

Getting error NoClassDeffound error while exceuting selenium script(created with maven) , please help me to resolve this

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:259) at ...READ MORE

answered Apr 20, 2020 in Selenium by celine
6,242 views
0 votes
0 answers
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
2 answers

TestNG error:- Cannot find class in classpath

The above link didn't work it means ...READ MORE

answered Feb 12, 2020 in Selenium by Rashmi Reddy PR
40,979 views
+1 vote
1 answer

Nightwatch chromedriver error

You should use a dot before lib: "webdriver.chrome.driver" ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,500 points
2,730 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP