 Okay, so the next talk is about SQL Alchemy by Yash Merotra Okay, so first of all, I'm gonna start with a show of hands How many of you work with relational databases? Okay, that's awfully lot Okay, and out of those how many of you use Django and am I right to assume that you use the Django RM? I think I'm anybody who doesn't anybody who has heard of SQL Alchemy by the way, okay, that's cool So anyway for those who don't know It's a no RM. I'm Yash Merotra. I'm a student open source evangelist So today, I'm just gonna tell you about a little bit about SQL Alchemy How does it work? Why many people find it better than the Django RM and Why many people consider the best RM out there? So what is a SQL Alchemy? It's basically a toolkit and I know RM it provide this is basically from the website. So It doesn't really you can read it But what it basically means is if you use a relational database and you're writing Roy's hill queries. It's time for a change It is more secure it you don't have to manually escape characters to prevent injections and it's more pythonic and Orem is an object relational matter mapper. It basically creates a You can basically create a DDL in your code like a class and then the table name and then you can write the columns in your class I'll show you the code snippets later How does it work and So it extra basically one thing which SQL Alchemy does better than Django is it Excesses more layers of the Django of the SQL SQL compared to Django I think Django RM just accesses the top layer and you can't do many customizable many you can't customize many things with it But with SQL Alchemy you get a bit more power. You feel like you you're controlling most things So why is kill Alchemy? first of all like It's more pythonic. I think many of you must have used a post-save signal and Has anybody tried to overwrite the safe method in Django RM? Yeah, so some people have so it's a good way and many people and in stagal You'll find it the first answer, but I don't consider it very pythonic So SQL Alchemy has event listeners. You can add event listeners for a table pre-insert after insert It's works like triggers so Yeah, that's more it it's more also it's Syntax is consistent like an SQL Alchemy if you are doing a query You just write session dot query than the table name and then you write filter Like say you have to see which persons Get a list of people whose age is greater than 30. So you can write this filter user dot age greater than equal to 30 Something like that and it's similar everywhere But in Django for that you have to write like underscore underscore gte or underscore underscore gte And if you're working with multiple foreign keys, it's like underscore underscore Then the table name underscore underscore. So it really is Crumbles it doesn't look nice So if you are interested in SQL Alchemy, it's very simple to start just pip install SQL Alchemy and Okay, so the first imports you can leave that This engine part is basically you it works with by the way, it works with all the RDS oracle SQL light Postgres mysql Okay, and now I'm just going to give you an example here like a class user And it has a table name user three columns id name email and when I do base dot meta dot create all engine so imagine I have multiple classes like this and This command basically creates all the tables in whatever in whatever database you specify here So it's very clean and it's much more easy to handle This is the SQL Alchemy API say I have created three users and I added them Actually, this was going to be a livedom of the code but due to some problem with HDMI port I couldn't give it so querying is simply easy session dot query table name and If you want to do something specific you can session dot query filter and double equal to you can search by email So for update basically what I did is if I need to update my name to my full name So I took that object I changed its name and then I added it to the session and I committed it so it's pretty simple and If you are working with Django RM you can shift it shift to SQL Alchemy There's a tool called algemy ALT JEM Y if you want it and then Similarly, you can delete Delete with the session and basically you can do a lot of things so I Don't know how many of you will try it, but I do suggest like Just give SQL Alchemy a try for those who do complex SQL operations Inner joints lots of outer joints or who may be facing some scaling problems due to relational databases In their Django websites. I highly suggest them to try SQL Alchemy and that's it. Thank you any questions for me Okay, thank you