import%20marimo%0A%0A__generated_with%20%3D%20%220.22.0%22%0Aapp%20%3D%20marimo.App(%0A%20%20%20%20width%3D%22medium%22%2C%0A%20%20%20%20layout_file%3D%22data%3Aapplication%2Fjson%3Bbase64%2CewogICJ0eXBlIjogInNsaWRlcyIsCiAgImRhdGEiOiB7fQp9%22%2C%0A%20%20%20%20sql_output%3D%22pandas%22%2C%0A)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20os%0A%20%20%20%20import%20sqlalchemy%0A%0A%20%20%20%20_password%20%3D%20os.environ.get(%22POSTGRES_PASSWORD%22%2C%20%22example%22)%0A%20%20%20%20DATABASE_URL%20%3D%20f%22postgresql%3A%2F%2Fpostgres%3A%7B_password%7D%40localhost%3A5432%2Fehrexample%22%0A%20%20%20%20engine%20%3D%20sqlalchemy.create_engine(DATABASE_URL)%0A%20%20%20%20return%20engine%2C%20os%0A%0A%0A%40app.cell%0Adef%20_(engine%2C%20mo)%3A%0A%20%20%20%20df%20%3D%20mo.sql(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20%20%20%20%20SELECT%20*%20FROM%20ehr.patients%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20engine%3Dengine%0A%20%20%20%20)%0A%20%20%20%20return%20(df%2C)%0A%0A%0A%40app.cell%0Adef%20_(df)%3A%0A%20%20%20%20df.to_csv(%22examples%2Foutput.csv%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(os)%3A%0A%20%20%20%20last_run%20%3D%20os.environ.get(%22MARIMO_PARAM_LAST_RUN_AT%22%2C%20%22%22)%0A%20%20%20%20with%20open(%22examples%2Foutput.txt%22%2C%20%22w%22)%20as%20f%3A%0A%20%20%20%20%20%20%20%20f.write(last_run)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
1b7c810f6249a059f7f6de722fd11f17