-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
add25a2
commit 6eef5b0
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
## Chapter 13: Database Integration | ||
With LangChain, you can integrate with databases and build systems that answer questions based on structured data. | ||
|
||
``` | ||
from langchain import OpenAI, SQLDatabase, SQLDatabaseChain | ||
# | ||
db = SQLDatabase.from_uri("sqlite:///chinook.db") | ||
# LLM | ||
llm = OpenAI(temperature=0) | ||
# | ||
db_chain = SQLDatabaseChain(llm=llm, database=db, verbose=True) | ||
# | ||
query = "How many tracks are there in the album with ID 1?" | ||
print(db_chain.run(query)) | ||
``` |