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

Create a Sqlite connector utility #1244

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

austinweisgrau
Copy link
Collaborator

Should follow #1242

Works with query(), copy(), and the DB sync utilities

@austinweisgrau austinweisgrau force-pushed the sqlite branch 2 times, most recently from b9811b5 to 1f97353 Compare January 19, 2025 23:33
@shaunagm
Copy link
Collaborator

@austinweisgrau just to clarify, are this and #1243 meant to be tested/reviewed/merged after #1242 is merged? Is that why the tests are failing? Or is that unrelated?

@austinweisgrau
Copy link
Collaborator Author

Yes, the tests in this PR use the refactored code in #1242 so this should only be merged after #1242 is approved and merged.

The tests are failing because I haven't figured out how to get sqlite properly installed and accessible in the github actions test environment, so that's a work in progress. (Tests should be passing on a local setup, it's a github actions specific issue. I think.)

@austinweisgrau
Copy link
Collaborator Author

Although it might be a windows issue specifically since that's the tests that are failing, so that's another avenue to look into

@bmos
Copy link
Contributor

bmos commented Jan 31, 2025

So this is to connect to a local SQL instance and SQL is not installed within the GitHub Actions environment?

I'd suggest an actions step of installing SQL via apt on Linux and winget on Windows. Not. Sure about macOS.

@bmos
Copy link
Contributor

bmos commented Jan 31, 2025

That being said, you might not actually need SQL installed to test the connector properly. There might be a Pytest SQL plugin or something which acts like an SQL instance.

You might want to look at the MySQL connector to see how they're doing it there.

@austinweisgrau
Copy link
Collaborator Author

The test actually is appropriately failing, I realized. Even though sqlite3 comes with python as part of the stdlib, on windows machines and probably other misc architectures, the sqlite3 cli utility isn't available by default.

One of the methods in the connector attempts to use the shell utility through a subprocess, but that won't work if the shell utility isn't installed and on path.

I'm going to modify that behavior to check if the shell utility is available first, and use a fallback behavior if it is not.

@austinweisgrau austinweisgrau force-pushed the sqlite branch 2 times, most recently from 16dbe98 to 896564d Compare February 13, 2025 23:49
responding to a bandit security check which flagged shell=True as
vulnerable to injection attacks
Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  parsons/databases
  db_sync.py
  table.py
  parsons/databases/sqlite
  __init__.py
  sqlite.py 48-49, 152, 157, 159, 161, 173, 271, 273, 293, 306-309
  parsons/etl
  etl.py
  test/test_databases
  test_dbsync.py
  test_sqlite.py 38, 50
Project Total  

This report was generated by python-coverage-comment-action

@austinweisgrau
Copy link
Collaborator Author

yay

@austinweisgrau
Copy link
Collaborator Author

cool security check @bmos , very helpful

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.

3 participants