betodealmeida / shillelagh

Making it easy to query APIs via SQL
MIT License
400 stars 54 forks source link

Segmentation fault while using `gsheets` dialect #420

Open tijoseymathew opened 10 months ago

tijoseymathew commented 10 months ago

Describe the bug I am encountering a segmentation fault when using the SQLAlchemy library with the gsheets dialect. The issue occurs when attempting to add a new record to a Google Sheets-backed database and committing the session.

To Reproduce

import uuid

from sqlalchemy import create_engine, Column, String
from sqlalchemy.orm import declarative_base, sessionmaker

engine = create_engine(
        'gsheets://',
        service_account_file="google_auth.json",
        catalog = {
            "users": (
                "https://docs.google.com/spreadsheets/d/TRUNCATED/edit?"
                "headers=1"
                "#gid=0"
                ),
            }
        )

Base = declarative_base()
class User(Base):
    __tablename__ = "users"
    id = Column(String, primary_key=True, nullable=False, autoincrement=False)
    name = Column(String)

SessionMaker = sessionmaker(bind=engine)
session = SessionMaker()
new_rec = User(id=uuid.uuid4(), name="Test")
session.add(new_rec)
session.commit()
print("DONE")

The row is successfully appended to the Google sheet.

Screenshots image image

Expected behavior I expected the code to work without any segmentation faults.

Desktop:

betodealmeida commented 10 months ago

This is hard to debug. What architecture are you using, and what version of apsw do you have? (you can run SELECT VERSION() to see the version.)

tijoseymathew commented 10 months ago

I tested on two machines with the following config and experienced Segmentation fault

$ lscpu | grep Architecture
Architecture:                       x86_64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy
$ python -c "import apsw; print(apsw.apswversion())"
3.44.2.0

Do let me know if you need any other info. Thanks!

Note: I missed out 'google-auth==2.26.2' in OP, added it