sql-assignment-generator 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/PKG-INFO +2 -2
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/pyproject.toml +2 -2
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/requirements.txt +2 -2
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/assignments/dataset.py +9 -6
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/assignments/exercise.py +5 -1
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/.env.template +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/.gitignore +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/.readthedocs.yaml +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/LICENSE +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/Makefile +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/README.md +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/docs/Makefile +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/docs/conf.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/docs/index.rst +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/docs/make.bat +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/docs/requirements.txt +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/__init__.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/assignments/__init__.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/assignments/assignment.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/constraints/__init__.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/constraints/base.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/constraints/query.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/constraints/schema.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/difficulty_level.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/domains.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/llm/__init__.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/llm/chatgpt.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/llm/message.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/llm/models.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/query_sintax.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/src/sql_assignment_generator/sql_errors_details.py +0 -0
- {sql_assignment_generator-0.0.6 → sql_assignment_generator-0.0.8}/test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sql_assignment_generator
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: This project generates SQL assignments based on common mistakes made by learners.
|
|
5
5
|
Project-URL: Repository, https://github.com/DavidePonzini/sql_assignment_generator
|
|
6
6
|
Project-URL: Documentation, https://sql-assignment-generator.readthedocs.io/en/latest/index.html
|
|
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Requires-Python: >=3.11
|
|
14
14
|
Requires-Dist: dotenv
|
|
15
15
|
Requires-Dist: pydantic
|
|
16
|
-
Requires-Dist: sql-error-categorizer
|
|
16
|
+
Requires-Dist: sql-error-categorizer>=0.1.10
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
19
|
# sql-assignment-generation
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sql_assignment_generator"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.8"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Davide Ponzini", email="davide.ponzini95@gmail.com" },
|
|
10
10
|
]
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
20
|
"pydantic",
|
|
21
|
-
"sql_error_categorizer",
|
|
21
|
+
"sql_error_categorizer>=0.1.10",
|
|
22
22
|
"dotenv",
|
|
23
23
|
]
|
|
24
24
|
|
|
@@ -6,7 +6,7 @@ from sql_error_categorizer.sql_errors import SqlErrors
|
|
|
6
6
|
from ..sql_errors_details import ERROR_DETAILS_MAP
|
|
7
7
|
from ..difficulty_level import DifficultyLevel
|
|
8
8
|
from ..constraints.schema import TableAmountConstraint, ColumnAmountConstraint, InsertAmountConstraint, HasCheckConstraint, HasSamePrimaryKeyConstraint
|
|
9
|
-
|
|
9
|
+
import sqlglot
|
|
10
10
|
|
|
11
11
|
@dataclass
|
|
12
12
|
class Dataset:
|
|
@@ -27,8 +27,8 @@ class Dataset:
|
|
|
27
27
|
# Normalize schema name
|
|
28
28
|
schema = schema.lower().replace(' ', '_')
|
|
29
29
|
|
|
30
|
-
create_cmds = '\n'.join(self.create_commands)
|
|
31
|
-
insert_cmds = '\n'.join(self.insert_commands)
|
|
30
|
+
create_cmds = '\n\n'.join(self.create_commands)
|
|
31
|
+
insert_cmds = '\n\n'.join(self.insert_commands)
|
|
32
32
|
|
|
33
33
|
return f'''BEGIN;
|
|
34
34
|
|
|
@@ -96,6 +96,8 @@ COMMIT;'''
|
|
|
96
96
|
try:
|
|
97
97
|
json_risposta = llm.generate_answer(messages, json_format=llm.models.Schema)
|
|
98
98
|
|
|
99
|
+
assert isinstance(json_risposta, llm.models.Schema), "The response is not in the expected JSON format."
|
|
100
|
+
|
|
99
101
|
#parsing CREATE TABLE
|
|
100
102
|
parsed_tables = []
|
|
101
103
|
try:
|
|
@@ -124,7 +126,8 @@ COMMIT;'''
|
|
|
124
126
|
elif isinstance(constraint, (TableAmountConstraint, ColumnAmountConstraint, HasCheckConstraint, HasSamePrimaryKeyConstraint)):
|
|
125
127
|
is_satisfied = constraint.validate(None, parsed_tables)
|
|
126
128
|
|
|
127
|
-
else:
|
|
129
|
+
else:
|
|
130
|
+
is_satisfied = constraint.validate(parsed_inserts, parsed_tables)
|
|
128
131
|
|
|
129
132
|
if not is_satisfied: missing_requirements.append(constraint.description)
|
|
130
133
|
|
|
@@ -132,8 +135,8 @@ COMMIT;'''
|
|
|
132
135
|
if not missing_requirements:
|
|
133
136
|
dav_tools.messages.success(f"Dataset generated and validated successfully at attempt {attempt + 1}.")
|
|
134
137
|
return Dataset(
|
|
135
|
-
create_commands=
|
|
136
|
-
insert_commands=
|
|
138
|
+
create_commands=[cmd.sql(pretty=True, dialect='postgres') for cmd in parsed_tables],
|
|
139
|
+
insert_commands=[cmd.sql(pretty=True, dialect='postgres') for cmd in parsed_inserts],
|
|
137
140
|
domain=domain
|
|
138
141
|
)
|
|
139
142
|
|
|
@@ -24,6 +24,9 @@ class Exercise:
|
|
|
24
24
|
difficulty: DifficultyLevel
|
|
25
25
|
'''The difficulty level of the exercise.'''
|
|
26
26
|
|
|
27
|
+
error: SqlErrors
|
|
28
|
+
'''The SQL error type associated with the exercise.'''
|
|
29
|
+
|
|
27
30
|
@staticmethod
|
|
28
31
|
def generate(error: SqlErrors, difficulty: DifficultyLevel, dataset: Dataset, title: str) -> 'Exercise':
|
|
29
32
|
'''Generate a SQL exercise based on the specified parameters.'''
|
|
@@ -95,7 +98,8 @@ The exercise must have the following characteristics: {error_details.characteris
|
|
|
95
98
|
title=title,
|
|
96
99
|
request=answer.request,
|
|
97
100
|
solutions=[answer.solution],
|
|
98
|
-
difficulty=difficulty
|
|
101
|
+
difficulty=difficulty,
|
|
102
|
+
error=error
|
|
99
103
|
)
|
|
100
104
|
|
|
101
105
|
#validetion fail management
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|