-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Errors generated by table names containing spaces; unable to start sandman2ctl #186
Comments
Reporting possible progress, but also a new error: I got past the original error by extending the reflected class (as mentioned in the docs) like this: # user_models.py
from sandman2.model import db, Model
class DownstreamAccounts(db.Model, Model):
__tablename__ = '\'Downstream Accounts$\''
# ... and so on for each of the 8 tables...
class UpstreamLocations(db.Model, Model):
__tablename__ = '\'Upstream Locations$\'' The main script looks like this: #!/usr/bin/python3
from sandman2 import get_app
from user_models import *
user_models = [
DownstreamAccounts,
DownstreamContacts,
DownstreamLocations,
PartNumberCosts,
Sheet1,
UpstreamAccounts,
UpstreamContacts,
UpstreamLocations,
]
conn_str = 'mssql+pyodbc://user:pass@db_instance'
app = get_app(conn_str, user_models=user_models)
if __name__ == '__main__':
app.run(debug=True) 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? |
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.
The text was updated successfully, but these errors were encountered: