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

print result in console if in notebook mode #9

Closed
litaotao opened this issue Sep 24, 2015 · 1 comment
Closed

print result in console if in notebook mode #9

litaotao opened this issue Sep 24, 2015 · 1 comment

Comments

@litaotao
Copy link
Contributor

I think should print result in the output cell in notebook if "ipython notebook " and load this extension in the opened notebook.

screenshots: [ Please do not mind the mask on the screenshots, for I use some data of our company, just for security reasons, thanks a lot ]

input on notebook cell

screen_shot 2015-09-24 at 2 15 36 pm

#### output result in console

screen_shot 2015-09-24 at 2 15 53 pm

#### code related is here

https://github.com/jaysw/ipydb/blob/master/ipydb/plugin.py

def render_result(self, cursor, paginate=True,
                      filepath=None, sqlformat=None):
        """Render a result set and pipe through less.
        Args:
            cursor: iterable of tuples, with one special method:
                    cursor.keys() which returns a list of string columns
                    headings for the tuples.
        """
        if not sqlformat:
            sqlformat = self.sqlformat
        if filepath:
            out = open(filepath, 'w')
            sqlformat = 'csv'
        else:
            out = pager()
        with out as stdout:
            if sqlformat == 'csv':
                self.format_result_csv(cursor, out=stdout)
            else:
                asciitable.draw(cursor, out=stdout,
                                paginate=paginate,
                                max_fieldsize=self.max_fieldsize)
Will PR a fix if you guys agree with this advice
@jaysw
Copy link
Owner

jaysw commented Oct 3, 2015

Hi there,

Thanks for the very detailed description!
This issue is covered by the comments in #10. Closing as a duplicate.

@jaysw jaysw closed this as completed Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants