Schema lookup implementation#9
Conversation
| # Check the response type and transform accordingly | ||
| if model_class == int: | ||
| return int(unflattened_data["result"]) | ||
| # FIX : STILL ONLY GETS FIRST LINE OF RESPONSE |
There was a problem hiding this comment.
We can be a bit more defensive here i.e. do next / iter only if it is a list / iterator.
There was a problem hiding this comment.
Probably not needed. It is test specific and can be in test_schema_discovery.
|
|
||
| create_bike_db() | ||
|
|
||
| query = common.create_query(db_url=f"sqlite:///{BIKES_DB_PATH}") |
There was a problem hiding this comment.
It would be better to give schema discovery as an option i.e. set it as following parameters
schema=None, schema_file=None, schema_inspect=False
If schema_inspect is true, none of the other two should be passed or it raises an error. Otherwise, one of schema_file or schema string should be passed.
Gives more flexibility to the developer (user) of the library that way.
| """Base test class for database-driven tests with common setup and helper methods.""" | ||
|
|
||
| db_url = DB_URL | ||
| db_url = "sqlite:///:memory:" |
| self.system_prompt = system_prompt or self.load_file(system_prompt_path) | ||
| else: | ||
| self.system_prompt = DEFAULT_SYSTEM_PROMPT | ||
|
|
|
|
||
| __sql__ No newline at end of file | ||
| __sql__ | ||
| fixtures No newline at end of file |
There was a problem hiding this comment.
Why this addition of fixtures?
anshum4n-git
left a comment
There was a problem hiding this comment.
Looks like I missed submitting this review. Take a look at the comments. Also, if we can separate out this PR and #10 for Multiple database support, they can be merged separately.
Summary
This PR implements support for schema lookup directly from the connected database when generating SQL queries, addressing think41/foundation-sql#8. Previously, a
schema.sqlfile or a hardcoded schema string was required for schema understanding. With this change, the system can now retrieve schema information dynamically from the database.Related Issue
Closes #8
Changes
schema.sqlor schema is not present.Additional Notes