Postgres showing Error: syntax error at end of input

Postgres showing Error: syntax error at end of input

我正在连接数据库并使用 python 在其中创建模式和表。

下面的查询给我语法错误。

Traceback (most recent call last):
  File "/home/rsharma/Documents/EBI_PPI_mutations/ebi_ppi_v2.py", line 22, in <module>
    """)
psycopg2.errors.SyntaxError: syntax error at end of input
LINE 7:

查询如下:

import psycopg2
import csv

connect_str = "dbname='x' user='xx' host='xxx' " "password='xxxx' port = xxxxx"
# use connection values to establish a connection
conn = psycopg2.connect(connect_str)
# create a psycopg2 cursor that can execute queries
cursor = conn.cursor()

# create schema in dev_bi
cursor.execute("""
CREATE SCHEMA IF NOT EXISTS ebi_mut_db;
""")

# create table in ebi_mut_db schema
cursor.execute("""
CREATE TABLE IF NOT EXISTS ebi_mut_db.version_info(
version INT,
download_date DATE,
download_url text,
responsible text
""")

# create table in ebi_mut_db schema
cursor.execute("""
CREATE TABLE IF NOT EXISTS ebi_mut_db.mutations_affecting_interactions(
Feature_AC text,
Feature_short_label text)
""")

conn.commit()

如果我遗漏了什么,我无法弄清楚。

谢谢

创建 table

时必须关闭括号
# create table in ebi_mut_db schema
cursor.execute("""
CREATE TABLE IF NOT EXISTS ebi_mut_db.version_info(
version INT,
download_date DATE,
download_url text,
responsible text)
""")