import psycopg2
def creat_tabel()。
conn=psycopg2.connect("dbname='database1' user='postgres' password='postgres123' host='localhost' port='5432'" /span>)
cur=conn.cursor()
cur.execute("CREATE TABLE ?F NOT EXISTS store (item TEXT , quantity INTEGER , price REAL)"/span>)
conn.commit()
conn.close()
創建標簽(creat_tabel)
這是我的代碼,這是我的錯誤。我怎樣才能解決它呢?請幫助。
C:Userssinan urgunDesktoppythondb> script2_postgresql.py
回溯(最近一次呼叫)。
檔案 "C:Userssinan urgunDesktoppythondbscript2_postgresql.py", line 10, in <module>
creat_tabel()
檔案 "C:Userssinan urgunDesktoppythondbscript2_postgresql.py", line 4, in creat_tabel
conn=psycopg2.connect("dbname='database1' user='postgres' password='postgres123' host='localhost' port='5432'" /span>)
檔案 "C:Userssinan urgunAppDataLocalProgramsPythonPython39libsite-packagespsycopg2\__init__.py", 行 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError
uj5u.com熱心網友回復:
你的SQL中出現了一個錯誤。你寫了 "?F",其中第一個字符是U 0130 : LATIN CAPITAL LETTER I WITH DOT ABOVE。你想用 "IF "來代替。
你可以在你的問題中看到I上方的點;你也應該可以在你的本地編輯器中看到這一點。如果這是一個經常性的問題,你可能想嘗試使用不同的字體,使問題更加明顯。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/331580.html
標籤:
