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

Getting error: "Connection failed" #8

Open
hemantaggarwal opened this issue Dec 24, 2019 · 2 comments
Open

Getting error: "Connection failed" #8

hemantaggarwal opened this issue Dec 24, 2019 · 2 comments

Comments

@hemantaggarwal
Copy link

hemantaggarwal commented Dec 24, 2019

I installed gsheetsdb package and tried to use it in superset and in python script but I am getting connection failed error. What should be the full uri for gsheets?

Kindly help in this issue.

@hemantaggarwal hemantaggarwal changed the title Getting error "NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:gsheets" Getting error: "Connection failed" Dec 25, 2019
@JagritiG
Copy link

JagritiG commented Jan 16, 2021

I have Installed package 'gsheetsdb' (version=0.1.12) and other dependencies from the requirement.txt file. Then, I have run the following code in PyCharm:

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

# Connection and authentication
service_account_file = "service_account_file.json"    # your service account credential file
engine = create_engine('gsheets://', service_account_file=service_account_file, subject='[email protected]')
inspector = inspect(engine)
url = "google_spread_sheet_url"

# Processing
table = Table(
    url,
    MetaData(bind=engine),
    autoload=True)

query = select([func.count(table.columns.cnt)], from_obj=table)
print(query.scalar())

Note: This works for me. You can try using a python script.

@hemantaggarwal
Copy link
Author

Thanks @JagritiG for the comment. I have started using a different approach but this will be helpful in future.

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