All exam details extracted successfully. Traceback (most recent call last): File…
- User
All exam details extracted successfully. Traceback (most recent call last): File "d:\Questionbank\proto1.py", line 124, in insert_exam_details conn = psycopg2.connect(**db_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Questionbank.venv\Lib\site-packages\psycopg2_init_.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "postgres"
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "d:\Questionbank\proto1.py", line 146, in insert_exam_details if conn: ^^^^ UnboundLocalError: cannot access local variable 'conn' where it is not associated with a value
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "d:\Questionbank\proto1.py", line 200, in main() File "d:\Questionbank\proto1.py", line 197, in main insert_exam_details(exam_details, DB_PARAMS) File "d:\Questionbank\proto1.py", line 151, in insert_exam_details if cursor: ^^^^^^ UnboundLocalError: cannot access local variable 'cursor' where it is not associated with a value how do i find requied values from my pgadmin gui, the database name is Questionbank and owner is postgres
- Assistant
- User
where can i find password for my database in pg admin, I havent set up one
- Assistant
If you haven't explicitly set a password for your PostgreSQL user (commonly "postgres"), you might encounter authentication issues. By default, PostgreSQL requires password authentication for remote connections, which can include connections via your local applications if configured that way.
- User
how do i see values in table exams
- Assistant
- User
Parsed Exam Details: Exam Name: Assistant Engineer (Civil), Class-2, Roads and Building Department Exam Date: 2019-06-23 Advertisement Number: 79/2018-19 Exam Code: None
All exam details extracted successfully. Error inserting exam details: column "advertisement_number" of relation "exams" does not exist LINE 2: INSERT INTO exams (exam_name, advertisem... ^
- Assistant
The error message indicates that there is a
column "advertisement_number" of relation "exams" does not exist. This suggests that your table does not have a column named , yet your insert operation attempts to insert data into this non-existent column. To resolve this, you need to do the following: - User
how do i add that column
- Assistant
To add a column named
advertisement_numberto yourexamstable in PostgreSQL, follow the steps using either PgAdmin or thepsqlcommand-line interface:Method 1: Using PgAdmin
-
Open PgAdmin:
-
- User
How do i change the regex pattern in this : def parse_questions_and_options(text): questions = [] options = []
# Split text into question blocks based on "Que. No." question_blocks = re.split(r'Que\.?\s*No\.?\s*\d+\s*-\s*\d+\s*GS & Concerned Subject', text, flags=re.IGNORECASE) for block in question_blocks[1:]: # Skip the first split as it precedes the first question # Further split into individual questions individual_questions = re.split(r'Que\.?\s*No\.?\s*\d+', block, flags=re.IGNORECASE) for iq in individual_questions[1:]: # Skip the first split # Extract question number and text q_text_match = re.match(r'\s*(\d+)\.\s*(.*)', iq, re.DOTALL) if q_text_match: q_number = int(q_text_match.group(1).strip()) q_text = q_text_match.group(2).strip() # Extract options opts = re.findall(r'\(([A-D])\)\s*(.*?)\n', q_text, re.DOTALL) option_dict = {} for opt in opts: label = opt[0] opt_text = ' '.join(opt[1].strip().split()) # Normalize whitespace option_dict[label] = opt_text # Remove options from question text q_text_clean = re.sub(r'\([A-D]\)\s*.*?\n', '', q_text, flags=re.DOTALL).strip() questions.append(q_text_clean) options.append(option_dict) return questions, options to extract question in this format : 102. The plan of a map was photocopied to a reduced size such that a line originally 120 mm, measures - Assistant