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

Open spreadsheet as database, worksheets as tables? #6

Open
jrjsmrtn opened this issue Oct 8, 2019 · 0 comments
Open

Open spreadsheet as database, worksheets as tables? #6

jrjsmrtn opened this issue Oct 8, 2019 · 0 comments

Comments

@jrjsmrtn
Copy link

jrjsmrtn commented Oct 8, 2019

Wouldn't it be easier to open the Google spreadsheet as a database, then use worksheets as tables? And eliminate the need for an intermediate catalog?

Like this:

from sqlalchemy import *
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import *

engine = create_engine("gsheets://1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8")
inspector = inspect(engine)

table = Table(
    "Simple sheet",
    MetaData(bind=engine),
    autoload=True)
query = select([func.count(table.columns.country)], from_obj=table)
print(query.scalar())  # prints 3.0
@jrjsmrtn jrjsmrtn changed the title Open spreadsheet as database, select from worksheets? Open spreadsheet as database, worksheets as tables? Oct 8, 2019
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

1 participant