createengine創(chuàng)建一個數(shù)據(jù)庫鏈接的規(guī)范為:dialect+driver://username:password@host:port/database
如果password中不包含特殊字符隔箍,這樣直接寫是沒有問題的谓娃,但是password包含特殊字符,比如@蜒滩, 則需要進行轉(zhuǎn)換
engine = create_engine('postgresql://scott:tiger@localhost/mydatabase')
轉(zhuǎn)換的代碼如下:
import urllib.parse
urllib.parse.quote_plus("kx%jj5/g")