我就是这样做的…
import pyodbc cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};" "Server=server_name;" "Database=db_name;" "Trusted_Connection=yes;") cursor = cnxn.cursor() cursor.execute('SELECT * FROM Table') for row in cursor: print('row = %r' % (row,))
相关资源:
https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Windows
http://blogs.msdn.com/b/cdndevs/archive/2015/03/11/python-and-data-sql-server-as-a-data-source-for-python-applications.aspx
由于异步需求,django通道似乎需要pytest。如果您阅读了pytest文档,那么运行测试的命令是:
$ pytest
我没有真正使用频道,所以这可能需要更多的设置。pytest的文档: https://docs.pytest.org/en/latest/
您还可以考虑在django频道的教程中请求显式链接到该频道。