Guest User

Untitled

a guest
Feb 5th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [2]. (2) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (2)')
  2. File "C:UsersytalosDocumentsYtaloProjeto1Conexão.py", line 15, in conectar_com_banco
  3. conexao = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
  4. File "C:UsersytalosDocumentsYtaloProjeto1Conexão.py", line 18, in <module>
  5. cursor=conectar_com_banco('DW')
  6.  
  7. def conectar_com_banco(usuario):
  8. if usuario in 'DW':
  9. server = 'X'
  10. database = 'dw'
  11. username = 'teste'
  12. password = 'teste1'
  13. else:
  14. print('funcao_nao_encontrado')
  15. import pyodbc
  16. cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
  17. cur=cnxn.cursor()
  18. return(cur)
  19. cursor=conectar_com_banco('DW')
  20. cursor.execute("SELECT @@version;")
  21. row = cursor.fetchone()
  22. print(row)
Add Comment
Please, Sign In to add comment