Skip to content

Use read_sql in database guide#2604

Merged
freddyaboulton merged 3 commits into
mainfrom
use-from-sql-in-guide
Nov 4, 2022
Merged

Use read_sql in database guide#2604
freddyaboulton merged 3 commits into
mainfrom
use-from-sql-in-guide

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

Description

Simplify the "connect to database" guide by using pd.read_sql.

Also moves the associated space to the gradio org.

Closes: # (issue)

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Nov 4, 2022

Nice!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2022

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2604-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review November 4, 2022 18:47
This will make our app more secure by avoiding storing sensitive information as plain text in our application files.

```python
DB_USER = os.getenv("DB_USER")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the import statements so that the code is more complete

Suggested change
DB_USER = os.getenv("DB_USER")
import os
import pandas as pd
DB_USER = os.getenv("DB_USER")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And below, would import gradio as gr

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Nov 4, 2022

This is great thanks for the simplification @freddyaboulton! Notice that when I tried out the code on a fresh install, I also needed to have psycopg2 installed. Might make sense to have a list of required python dependencies

@freddyaboulton freddyaboulton merged commit f795a4d into main Nov 4, 2022
@freddyaboulton freddyaboulton deleted the use-from-sql-in-guide branch November 4, 2022 20:31
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

Successfully merging this pull request may close these issues.

2 participants