Django
is writing a program to read data from SQL Server
, but an object that is different from the actual database name is generated, resulting in an error.
The contents of the error are as follows, but I don't know why 'app_usertable' is generated.
The raw method produces the same error.
('42S02', "[42S02] [Microsoft] [ODBC Driver 17 for SQL Server] [SQL Server]Invalid object name 'app_usertable'. (208) (SQLExecDirectW); Failed to prepare [42S02] [Microsoft] [ODBC Driver 17 for SQL Server] [SQL Server] statement. (8180)"
models.py
class UserTable(models.Model):
userid=models.CharField(max_length=32)
username=models.CharField(max_length=32)
def__str__(self):
return self.name
views.py
data=UserTable.objects.filter(userid='sato')
for x in data:
print(x.userid)
Try building your model with manage.py inspectdb
instead of documentation.
It will probably work.
© 2024 OneMinuteCode. All rights reserved.