How to setup gino?

Hello I’m trying to setup a gino ORM in starlette but finding it difficult. I have placed listener on startup
db = Gino()
async def before_server_start():
await db.set_bind(‘postgresql://admin:admin@localhost/db’)
and on shutdown

async def server_exit():
await db.pop_bind().close()

listeners but when I try to connect it breaks with Gino engine is not initialized?

Any tutorial on Gino/Starlette best practices is highly appreciated!

So I have figured out that I have used another Gino() to define my User model, is there a way to pass ginoengine reference to Gino.Model()?

I imagined having a separate folder with Models defined but I am having issue passing db to them

Never worked without Gino myself, but you general setup using Starlette event handlers looks sensible to me!

How about declaring the db instance in a separate file, and then importing that same instance from the model files as well as the main application file?

Thats what I have done. Created db instance in models file and imported everything from there. If anyone has better boilerplate folder structure / code org it would be nice to hear about it!