I am trying to build a PostgreSQL database. I used the sample program provided by Google Colab, [postgres_python_connector.ipynb] at https://colab.research.google.com/github/GoogleCloudPlatform/cloud-sql-python-connector/blob/main/samples/notebooks/postgres_python_connector.ipynb#scrollTo=D3xMRsBl3Ihl.
I got an error of "ObjectNotExecutableError: Not an executable object: 'CREATE TABLE IF NOT EXISTS ratings ( id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, genre VARCHAR(255) NOT NULL, rating FLOAT NOT NULL, PRIMARY KEY (id));'" when I executed the following code:
# connect to connection pool
with pool.connect() as db_conn:
# create ratings table in our movies database
db_conn.execute(
"CREATE TABLE IF NOT EXISTS ratings "
"( id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, "
"genre VARCHAR(255) NOT NULL, rating FLOAT NOT NULL, "
"PRIMARY KEY (id));"
)
Please help! Thanks!
I also tried the MySQL version of sample code. It has the same error. Both versions were last modified about 6 months ago.