我在天藍(lán)色中創(chuàng)建了自己的數(shù)據(jù)庫,但現(xiàn)在沒有任何數(shù)據(jù)。我按照此文檔創(chuàng)建數(shù)據(jù)庫。我想創(chuàng)建表并使用 python 從我的機(jī)器訪問它。到目前為止我嘗試過的import mysql.connectorfrom mysql.connector import errorcode# Obtain connection string information from the portalconfig = { 'host': '<servername>.database.windows.net', 'user': '<username>@servername.database.windows.net', 'password': '<passwword>', 'database': '<DB name>'}# Construct connection stringtry: conn = mysql.connector.connect(**config) print("Connection established")except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: print("Something is wrong with the user name or password") elif err.errno == errorcode.ER_BAD_DB_ERROR: print("Database does not exist") else: print(err)但是當(dāng)我運(yùn)行它時(shí)它會(huì)拋出以下錯(cuò)誤9002 (28000): The server name you tried cannot be found: <servername>.database.windows.net. Please check the Username and retry connection. The Username should be in <username@hostname> format.我用我的憑證填寫了憑證。提前致謝我可以從 Microsoft SQL Server Management Studio 訪問為什么我無法通過Python訪問?
無法使用 python 從我的計(jì)算機(jī)訪問 Azure SQL DB
慕桂英4014372
2023-10-11 20:09:59