forked from maciej/prawo-jazdy-resources
No description
| .gitignore | ||
| database.db | ||
| LICENSE | ||
| main.py | ||
| pytania_z_punktacja_11_2025.csv | ||
| README.md | ||
| requirements.txt | ||
db-prawo-jazdy
Based on prawo-jazdy-resources by maciej, to better suit the needs of nuxt-prawo-jazdy
Files summary
main.py is a script that reads the file pytania_z_punktacja_11_2025.csv (it may change, depending on the age of the file and its outdatedness, but also sometimes the lack of point value ==> (blog post about such shenanigans in the future)) and imports it/them into a SQLite database file
database.dbSQLite file filled with data from the file abovepytania_z_punktacja_11_2025.csvis thepytania_egzaminacyjne_na_kierowcę_2025.xlsxfile converted to CSV (string delimiter;) from the website of the Polish Ministry of Infrastructure here - now the new file displayed at the main driver's license page doesn't contain the point value as opposed to the one provided above, in that case a writing to the Ministry is needed, asking for the public information of that value for each question ==> (blog post about such shenanigans in the future)
Requirements
- python3
- tqdm
Running
Just run python main.py IN THE SAME DIRECTORY AS THE SCRIPT IS LOCATED IN.
- If needed, modify the CSV file name inside the script AND SET THE ROWS ACCORDINGLY.
- Also check if your CSV file has a header on its first row, the file provided in this repository does have one, hence the
next(reader)command which skips the first row. If your script doesn't have such header, comment these lines out.
- Also check if your CSV file has a header on its first row, the file provided in this repository does have one, hence the
- If your CSV does not contain point values, contact the Ministry and get pairs of question IDs and their point values in CSV, then comment the lines below
## COMMENT OUT BELOW...and above## COMMENT OUT ABOVE, and uncomment the lines below## UNCOMMENT BELOWand above## UNCOMMENT ABOVE- Set rows accordingly.
- Also check if your point value CSV file has a header on its first row, the file provided in this repository does have one, hence the
next(reader)command which skips the first row. If your script doesn't have such header, comment these lines out.
Database structure
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER,
correct_answer TEXT,
media_url TEXT,
weight INTEGER
);
CREATE TABLE IF NOT EXISTS questions (
task_id INTEGER,
lang TEXT,
text TEXT
);
CREATE TABLE IF NOT EXISTS tasks_advanced (
id INTEGER,
correct_answer TEXT,
media_url TEXT,
weight INTEGER
);
CREATE TABLE IF NOT EXISTS questions_advanced (
task_id INTEGER,
lang TEXT,
text TEXT,
answer_a TEXT,
answer_b TEXT,
answer_c TEXT
);
CREATE TABLE IF NOT EXISTS categories (
name TEXT,
task_id INTEGER
);
Criteria
Categories:
- AM
- A1
- A2
- A
- B1
- B
- C1
- C
- D1
- D
- T
- PT
Languages as such:
- PL
- EN
- DE
- UA
Basic tasks query
According to the Ministry of Infrastructure, in an exam there are (basic):
- 4 questions for 1 point
- 6 questions for 2 points
- 10 questions for 3 points
Set below values accordingly to the requirements above or to your liking:
- NO_OF_QUESTIONS
- WEIGHT_OF_QUESTIONS
- LANG
- CATEGORY
SELECT
tasks.id,
tasks.correct_answer,
tasks.media_url,
tasks.weight,
questions.text
FROM tasks
LEFT JOIN questions ON tasks.id = questions.task_id
LEFT JOIN categories ON tasks.id = categories.task_id
WHERE
categories.name = CATEGORY AND
questions.lang = LANG AND
tasks.weight = WEIGHT_OF_QUESTIONS
ORDER BY random()
LIMIT (NO_OF_QUESTIONS);
Advanced tasks query
According to the Ministry of Infrastructure, in an exam there are (advanced):
- 2 questions for 1 point
- 4 questions for 2 points
- 6 questions for 3 points
Set below values accordingly to the requirements above or to your liking:
- NO_OF_QUESTIONS
- WEIGHT_OF_QUESTIONS
- LANG
- CATEGORY
SELECT
tasks_advanced.id,
tasks_advanced.correct_answer,
tasks_advanced.media_url,
tasks_advanced.weight,
questions_advanced.text,
questions_advanced.answer_a,
questions_advanced.answer_b,
questions_advanced.answer_c
FROM tasks_advanced
LEFT JOIN questions_advanced ON tasks_advanced.id = questions_advanced.task_id
LEFT JOIN categories ON tasks_advanced.id = categories.task_id
WHERE
categories.name = CATEGORY AND
questions_advanced.lang = LANG AND
tasks_advanced.weight = WEIGHT_OF_QUESTIONS
ORDER BY random()
LIMIT (NO_OF_QUESTIONS);