You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some existing MS SQL server tables that I need to migrate from Flask-admin to Flask-appbuilder. These tables contain columns with spaces such as [Column name 1], [Column name2].
While the app is working fine with flask-admin and SQLalchemy, I realised that the primary key column with such naming convention doesn't work with F.A.B
The F.A.B should display a table with three columns as shown in the script below.
Tell us what should happen.
The line #23 in the script below is the cause of the issue. After replacing it with line #24, the problem goes away. However, we cannot change the naming convention from Primary key 1 to primary_key_1 as this is the convention used in the EDW.
Steps to reproduce
run pip install -r requirements.txt using the requirements.txt provided below
Paste the full traceback if there was an exception.
AttributeError
AttributeError: 'TestTable' object has no attribute 'Primary key 1'
Traceback (most recent call last)
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 2213, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 2193, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask\app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\security\decorators.py", line 137, in wraps
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\views.py", line 551, in list
widgets = self._list()
^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\baseviews.py", line 1181, in _list
widgets = self._get_list_widget(
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\baseviews.py", line 1087, in _get_list_widget
pks = self.datamodel.get_keys(lst)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\models\base.py", line 296, in get_keys
return [getattr(item, pk_name) for item in lst]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Dev\flask-appbuilder-simpleview1\venv\Lib\site-packages\flask_appbuilder\models\base.py", line 296, in <listcomp>
return [getattr(item, pk_name) for item in lst]
^^^^^^^^^^^^^^^^^^^^^^AttributeError: 'TestTable' object has no attribute 'Primary key 1'
The text was updated successfully, but these errors were encountered:
agxc
changed the title
Bug: FAB cannot read tables with Oct 26, 2023
agxc
changed the title
Bug: FAB cannot read tables with primary key columns with spacesOct 26, 2023
Thank you @dpgaspar for such prompt reply 👍 . You are 100% right in pointing out the underlying issue, which is not quite to do with whitespace.
F.A.B doesn't support if I change line #25 to primary_key_1 = Column("PRIMARY_KEY_1", Integer, primary_key=True).
In our case, our source EDW holds thousands of tables with columns named like [Primary key x], [Column name x] which makes impossible for me to change the underlying column names. Plus there is an increasing popularity of using space as naming convention due to how MS SQL server handles metadata for Power BI.
I have been scratching my head for days trying to have a workaround so I am very excited to hear that this feature is going to be supported....!
I have some existing MS SQL server tables that I need to migrate from Flask-admin to Flask-appbuilder. These tables contain columns with spaces such as [Column name 1], [Column name2].
While the app is working fine with flask-admin and SQLalchemy, I realised that the primary key column with such naming convention doesn't work with F.A.B
Environment
Flask-Appbuilder version:
Flask-AppBuilder==4.3.9
pip freeze output:
werkzeug==2.3.7
Flask-AppBuilder==4.3.9
Describe the expected results
The F.A.B should display a table with three columns as shown in the script below.
Tell us what should happen.
The line #23 in the script below is the cause of the issue. After replacing it with line #24, the problem goes away. However, we cannot change the naming convention from
Primary key 1
toprimary_key_1
as this is the convention used in the EDW.Steps to reproduce
pip install -r requirements.txt
using therequirements.txt
provided belowpython app.py
requirements.txt
app.py
The text was updated successfully, but these errors were encountered: