How to create SQLagent using django models #20942
Replies: 2 comments
-
To achieve Django-like querying and interaction with your Django models directly, leveraging the LangChain framework's The For handling many-to-many relationships and linker tables, which are directly utilized in Django querying, the documentation and examples provided in the LangChain framework should offer guidance on configuring custom prompt templates. These templates can help in translating Django-like querying syntax into actual SQL queries that the In summary, using the LangChain framework's
|
Beta Was this translation helpful? Give feedback.
-
@thondeboer Did you make any progress with this? I'm in a similar boat. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to learn how to use Django model and their definitions to enable searching and reasoning over DJANGO models directly, not using postgresql language or if so, how to automatically extract the database information, including the ForeignKey definitions.
I have a Django model definition for about 30 tables, which have very elaborate help_texts that could be useful for a LLM model to understand the contents of the table and they also contain many foreignkeys to link to other database, as per usual in a SQL database.
I can extract those fields and attempt to make a SQLSchema, but the names of the fields in a django model, don't always correspond with the column names, especially when ForeignKeys are involved. A field called "concept" that is a foreign_key to a another model, will be column "concept_id" in the table, so this complicates the SQLschema definition (can ofcourse program it to add _id, for type==foreignkey etc.
But there are also other complicated many_to_many relationships with linker tables etc. that DJANGO querying can directly use....
So, I guess I am looking for a LLM that can create DJANGO query languge code to execute or another method to efficiently do DJANGO-like querying.
Is SQLagent using direct access to postgres DB my only viable option (Other than me training a model specifically in DJANGO query langugage)
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
Beta Was this translation helpful? Give feedback.
All reactions