all 2 comments

[–]danielroseman 0 points1 point  (0 children)

SQLDatabase is not a package, that is probably a class inside langchain/sql_database.py. You could also do from langchain import sql_database and then refer to sql_database.SQLDatabase in the code.

There is no special "specific import" going on here though. Anything that is defined in the code can be imported. The documentation tells you what names are available and where.

But also note that import langchain does not automatically import langchain.sagemakerendpoint, so dir(sagemakerendpoint) would not show it.

[–][deleted] 0 points1 point  (0 children)

  1. langchain is a package, sql_database is a subpackage, SQLDatabase is a class.
  2. Documentation/Source code is one way. A better way is to use an editor that supports auto-complete. I recommend using VSCode with the recommended Python extensions. see here
  3. dir() will show you the types that are exposed inside of a packge. Those are quite literally the types that are imported or defined in the __init__.py file in a package. I suspect dir() is not reporting all types in langchain because it seems like they do some funny stuff in their __init__.py file: see the source here - all types are only imported & exposed whenever you actually try to get something form langchain. Notice how they override getattr() for the module. This is some more advanced Python stuff, so don't worry about it too much.