Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the jupyter_client API to assign SQL output to variables #93

Open
tmthyjames opened this issue Sep 17, 2017 · 1 comment
Open

Use the jupyter_client API to assign SQL output to variables #93

tmthyjames opened this issue Sep 17, 2017 · 1 comment
Assignees

Comments

@tmthyjames
Copy link
Owner

Currently I'm assigning variables using the __builtins__ module.

I think the better way to accomplish this is using the BlockingKernelClient class from the jupyter_client API.

Maybe the following:

from jupyter_client.blocking import BlockingKernelClient

kc = BlockingKernelClient()
kc.load_connection_info(<connect_info>)
kc.start_channels()

Then to create variables do kc.execute('foo = "bar"')

@tmthyjames
Copy link
Owner Author

To pass a dataframe we could do:

code = """
import pandas as pd
{0} = pd.DataFrame({1})
{0}.columns = {1}[0].keys()
""".format(var_name, data)

kc.execute(code)

Something like this should work.

@ghost ghost assigned tmthyjames Oct 15, 2017
@ghost ghost added the in progress label Oct 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant