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

Add import_dbapi() to mimic dbapi() to prevent SADeprecationWarning #452

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

RyanJulyan
Copy link
Contributor

  • fix(backends\apsw\dialects\base.py): prevent SADeprecationWarning: Add import_dbapi() to mimic dbapi() to prevent SADeprecationWarning

Summary

prevent SADeprecationWarning: Add import_dbapi() to mimic dbapi() to prevent SADeprecationWarning

Testing instructions

What steps can be taken to manually verify the changes?

Install latest SQLAlchemy pip install sqlalchemy run the following code:

from sqlalchemy import create_engine, text

# Create the engine
engine = create_engine(
    "shillelagh://",
    adapters=["csvfile"]
)

# Connect to the engine
connection = engine.connect()

# Correct file path
csv_file_path = "C:/Users/<user_name>/adaptor_test/test.csv"
query = text(f"SELECT * FROM '{csv_file_path}'")

try:
    # Execute the query and fetch results
    result = connection.execute(query)

    # Print the results
    for row in result:
        print(row)
except Exception as e:
    print(f"Error: {e}")

and observe warning:

SADeprecationWarning: The dbapi() classmethod on dialect classes has been renamed to import_dbapi().  Implement an import_dbapi() classmethod directly on class <class 'shillelagh.backends.apsw.dialects.base.APSWDialect'> to remove this warning; the old .dbapi() classmethod may be maintained for backwards compatibility.
  engine = create_engine(

apply fix in PR and the warning is gone.

SADeprecationWarning: The dbapi() classmethod on dialect classes has been renamed to import_dbapi().  Implement an import_dbapi() classmethod directly on class <class 'shillelagh.backends.apsw.dialects.base.APSWDialect'> to remove this warning; the old .dbapi() classmethod may be maintained for backwards compatibility.
  engine = create_engine(
@betodealmeida
Copy link
Owner

Thanks, @RyanJulyan!

@betodealmeida betodealmeida enabled auto-merge (squash) June 4, 2024 15:21
@betodealmeida betodealmeida merged commit d675a22 into betodealmeida:main Jun 4, 2024
2 of 8 checks passed
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.

None yet

2 participants