mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-04-27 01:25:53 +03:00
[GH-ISSUE #186] Errors generated by table names containing spaces; unable to start sandman2ctl #67
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#67
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @thomascapote on GitHub (Nov 19, 2020).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/186
Jeff:
First, kudos and thanks for this project. Beautiful stuff!
I'm working with a SQL Server database that is not "beautiful stuff". ;-) Specifically, the database contains the following table names.
Strangely, the single quotes are also part of the table names. Querying these tables in the SQL Server toolset looks like this:
SELECT * FROM ['Upstream Contracts$'].Running
sandman2ctl "$db_uri"takes a while, then throws an error:sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near 'Downstream'. (102) (SQLExecDirectW)").The same error is thrown by python3 when running the following interactively in the REPL (not using
sandman2ctl).The same error is thrown with-or-without the exclude_tables parameter. Here's the full traceback:
My understanding was that SQLAlchemy's introspection routine handled all necessary quoting for special characters, but it seems to be failing here.
@thomascapote commented on GitHub (Nov 19, 2020):
Reporting possible progress, but also a new error:
... could not assemble any primary key columns for mapped table...I got past the original error by extending the reflected class (as mentioned in the docs) like this:
The main script looks like this:
Running this generates the following error.
Here's the full stack trace.
Can I manually define the primary key column for SQLAlchemy in a similar fashion as I did the table name?