I’m currently trying to run SQL in Jupyter Notebook but seem to be having an issue with the magic commands.
When I run my script in the integrated Jupyter Notebook environment on DataQuest I have no issues but as soon as I try to run it in my own bowser the “%” turns black and I get errors. I am getting the same problem when I try to run it from the Jupyter extension in VS Code.
When you are reporting errors, please always make sure to report what those errors are, including any error messages and tracebacks.
Since you are describing two or three different environments, it seems likely that there is a difference of versions and packages available. For example, %load_ext sql assumes you have jupysql installed.
@minrk That fixed it though I am still not entirely sure what was wrong in the first place. A friend was able to run my code without jupysql. They had the following:
MetaData.__init__() got an unexpected keyword argument 'bind'
Connection info needed in SQLAlchemy format, example:
postgresql://username:password@hostname/dbname
or an existing connection: dict_keys([])
and
Environment variable $DATABASE_URL not set, and no connect string given.
Connection info needed in SQLAlchemy format, example:
postgresql://username:password@hostname/dbname
or an existing connection: dict_keys([])
I made a post on StackOverflow that provides some more detail and screenshots: