1

I am connecting a database and creating a schema and tables in it using python.

The below query giving me syntax error.

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:

The query is as follows:

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()

I am unable to figure it out if I am missing anything.

Thanks

0

1 Answer 1

4

You must close the parentheses when creating the 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)
""")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.