How I started using odmantic #144
aahnik
started this conversation in
Show and tell
Replies: 1 comment
-
I agree! odmantic is truly fantastic! I use it mostly for discord bots and it's a breeze. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am an 18 yo beginner developer from India. I am building a "refer and earn" telegram bot for my friend. (currently a private project, but plan to open source it sometime in future)
I find it more natural and to think in terms of python objects. Pydantic is just awesome as it does everything so elegantly.
For rapid prototyping, I had just used an in-memory python dictionary with the user id as key, and the Person model as the value.
Previously my code was something like this in
storage.py
In other modules to access or manipulate the data, I did something like this
What I did was working, but I needed two things
I did not like the idea of using SQL, as I would be rapidly changing the structure of data in the future. I had never used MongoDB at this point. But I thought let me give it a shot. (I don't know much of theoretical stuff, just exploring!) Another reason I did not use SQL is that I found SQLAlchemy a little scary.
While I was searching the web and exploring GitHub, I found the magic wand! odmantic.
Odmantic made it absolutely easy for me to switch from my rough prototype to a serious and powerful MongoDB database.
Switching to
odmantic
was easy.At the entry point where I started my bot client, I also initialized my AIOEngine
Now in other modules to access or manipulate the data, I simply do like this.
From now on I think I will be using MongoDB with odmantic for my future projects. It's much easy to define the data structure, and everything is fast and fully scalable.
Thanks, @art049 for creating odmantic!
As of June 26th, 2021, the bot has nearly 5K users and everything seems to be working fine. I also did schema changes by adding new attributes to the Person model. As I had set a default value for the new fields, there was no issue.
Anyone reading this feel free to suggest improvements or comment about your experiences.
Beta Was this translation helpful? Give feedback.
All reactions