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,290 points
55 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,090 points

Related Questions In Selenium

+1 vote
2 answers

Getting this error: “Element is not clickable at point”

There are 3 possible solutions for this: 1. ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,650 points
19,633 views
0 votes
1 answer

Error: FF Browser not working for Selenium test after update

Since Firefox's latest update to version 47.0, ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,650 points
90 views
0 votes
1 answer

Is it possible for a website to detect that we are using Selenium with ChromeDriver

Selenium tests for pre-defined javascript variables which ...READ MORE

answered Apr 27, 2018 in Selenium by Meci Matt
• 9,420 points
2,168 views
0 votes
1 answer

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,090 points
548 views
0 votes
1 answer
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,130 points
881 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
546 views
0 votes
1 answer

TestNG error:- Cannot find class in classpath

The issue is because the project directory ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,090 points
6,819 views
+1 vote
1 answer

Nightwatch chromedriver error

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

answered Mar 25, 2018 in Selenium by nsv999
• 5,090 points
432 views