Closed zh-zhang1984 closed 1 year ago
Since you are not displaying the full error message, I am not completely sure, but most likely the reason is that the amsterdamumcdb.get_sepsis_patients(con) requires a SQLAlchemy engine, since a recent pandas update:
#Modify config.ini in the root folder of the repository to change the settings to connect to your postgreSQL database
import configparser
import os
config = configparser.ConfigParser()
if os.path.isfile('../../config.ini'):
config.read('../../config.ini')
else:
config.read('../../config.SAMPLE.ini')
#Open a connection to the postgres database:
pg_con = psycopg2.connect(database=config['psycopg2']['database'],
user=config['psycopg2']['username'], password=config['psycopg2']['password'],
host=config['psycopg2']['host'], port=config['psycopg2']['port'])
pg_con.set_client_encoding('WIN1252') #Uses code page for Dutch accented characters.
pg_con.set_session(autocommit=True)
cursor = pg_con.cursor()
cursor.execute('SET SCHEMA \'amsterdamumcdb\''); #set search_path to amsterdamumcdb schema
# create SQLAlchemy engine for official pandas database support
engine = sqlalchemy.create_engine('postgresql+psycopg2://', creator=lambda: pg_con)
con = engine.connect()
If you make sure that con
is a SQLAlchemy engine, it would most likely work.
yes, it works fine after adding the SQLAlchemy engine.
I have following code to extract sepsis patients, but it reported error; How can I solve this problem?