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

SQLAlchemy support #81

Closed
wants to merge 1 commit into from
Closed

SQLAlchemy support #81

wants to merge 1 commit into from

Conversation

dungdm93
Copy link
Member

@dungdm93 dungdm93 commented Apr 2, 2021

See #13

@findepi
Copy link
Member

findepi commented Apr 21, 2021

Let me know when this becomes non-draft.

@dungdm93
Copy link
Member Author

@findepi Do you know why CI say ModuleNotFoundError: No module named 'trino.sqlalchemy'?
I run test in my local machine, it works fine.

@hashhar
Copy link
Member

hashhar commented Apr 21, 2021

trino/__init__.py Outdated Show resolved Hide resolved
@findepi
Copy link
Member

findepi commented Apr 26, 2021

feat: support python 3.5

this shouldn't be needed. i just merged #83 so that you can drop this one

@dungdm93 dungdm93 force-pushed the sqlalchemy branch 2 times, most recently from bfdfc05 to f448713 Compare April 26, 2021 08:39
@findepi findepi requested a review from hashhar April 26, 2021 11:48
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in reviewing. Thanks a lot for your work.

A few comments.

I did not review feat: TrinoTypeCompiper datatypes yet.

Also, I did not completely understand datatype.py added in 66f6666.

trino/sqlalchemy/compiler.py Show resolved Hide resolved
trino/sqlalchemy/dialect.py Outdated Show resolved Hide resolved
else:
raise ValueError(f'Unexpected database format {url.database}')

username = kwargs.pop('username', 'anonymous')
Copy link
Member

Choose a reason for hiding this comment

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

Why provide a default username? The default for all other clients is an empty/missing username.
Also you can inline this into the line below.

Copy link
Member Author

Choose a reason for hiding this comment

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

If username is empty, we get this error:

trino.exceptions.HttpError: error 401: b'Basic authentication or X-Trino-User must be sent'

Copy link
Member

@ebyhr ebyhr Sep 3, 2021

Choose a reason for hiding this comment

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

@findepi @hashhar Do you think we should use OS username by default in Python client as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ebyhr is that implemented any where else (like CLI or JDBC)?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@dungdm93 dungdm93 Sep 12, 2021

Choose a reason for hiding this comment

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

@findepi @ebyhr @hashhar I think we should going to the same direction as JDBC does.

Copy link
Member Author

Choose a reason for hiding this comment

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

So now user is required.
This must be specify either in URL or in connect_args

engine = create_engine("trino://username@localhost:8080/mysql")

# or 
engine = create_engine(
        "trino://localhost:8080/mysql",
        connect_args=dict(user="username")
)

trino/sqlalchemy/dialect.py Outdated Show resolved Hide resolved
trino/sqlalchemy/dialect.py Outdated Show resolved Hide resolved
trino/__init__.py Show resolved Hide resolved
integration_tests/test_dbapi.py Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
trino/sqlalchemy/compiler.py Outdated Show resolved Hide resolved
trino/sqlalchemy/dialect.py Outdated Show resolved Hide resolved
@hashhar
Copy link
Member

hashhar commented May 30, 2021

@dungdm93 Did you get a chance to address the comments? I would really love to see this merged. Let me know if there's anything I can help with to push this over the finish line.

@dungdm93
Copy link
Member Author

dungdm93 commented Jun 2, 2021

Sorry @hashhar to let you waiting. I so busy recently. I’ll try to finish this task next week.

@buremba
Copy link
Member

buremba commented Aug 27, 2021

@dungdm93 Did you have time to add the comments? I can help and create another PR from this one if you're busy, please let me know in that case.

@dungdm93 dungdm93 force-pushed the sqlalchemy branch 7 times, most recently from ff00675 to 0ad3563 Compare September 2, 2021 09:53
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

3rd commit: "test: dialect.create_connect_args"

tests/sqlalchemy/test_dialect.py Show resolved Hide resolved
tests/sqlalchemy/test_dialect.py Show resolved Hide resolved
trino/auth.py Show resolved Hide resolved
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

4th commit: "refactor: change IsolationLevel to Enum"

Can we extract the formatting related changes to a separate first commit? It makes it much easier to see the places where actual changes have happenned.

A few comments. I'll do an in-depth review once again after reading up about the sqlalchemy api expectations.

tests/sqlalchemy/test_dialect.py Outdated Show resolved Hide resolved
trino/transaction.py Outdated Show resolved Hide resolved
trino/transaction.py Show resolved Hide resolved
@esemeniuc
Copy link

How is the current state of the port? Is it mostly usable?

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay @dungdm93.

I think it's almost ready to be merged % comments.

cc: @aalbu

tests/sqlalchemy/conftest.py Show resolved Hide resolved
tests/sqlalchemy/test_datatype_parse.py Show resolved Hide resolved
trino/__init__.py Show resolved Hide resolved
trino/dbapi.py Outdated Show resolved Hide resolved
trino/sqlalchemy/compiler.py Show resolved Hide resolved
trino/sqlalchemy/datatype.py Show resolved Hide resolved
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me. Couple of comments.

@findepi Do you want to take a look?

tests/sqlalchemy/test_datatype_parse.py Show resolved Hide resolved
tests/sqlalchemy/test_datatype_parse.py Show resolved Hide resolved
tests/sqlalchemy/test_datatype_parse.py Show resolved Hide resolved
tests/sqlalchemy/test_dialect.py Show resolved Hide resolved
trino/__init__.py Show resolved Hide resolved
trino/sqlalchemy/datatype.py Show resolved Hide resolved
trino/sqlalchemy/datatype.py Outdated Show resolved Hide resolved
trino/sqlalchemy/dialect.py Show resolved Hide resolved
trino/sqlalchemy/dialect.py Show resolved Hide resolved
@hashhar
Copy link
Member

hashhar commented Nov 25, 2021

Also, I can't see any way to logically keep the commits separate - please squash them into a single one.

Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
@dungdm93
Copy link
Member Author

@hashhar updated as your comments.
I also squash all commits and has some feedback.

@hashhar
Copy link
Member

hashhar commented Dec 2, 2021

Merged as da1441f (and preceding commits). There were some conflicts that I resolved (and split into commits). Your authorship is retained on all commits.

Thanks so much for continuing to work on this @dungdm93 and getting it merged. ❤️ This will be available in the next release which should follow soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.