Latest / Talk Python To Me / #353: SQLModel: The New ORM for FastAPI and Beyond
Transcript
- 0:00Two frameworks that have taken the Python world by storm lately are FastAPI and Pydantic.
- 0:05Once you already have your data exchange model in Pydantic, you might want to use that code for
- 0:10storing or talking to your database. And if you have database models, you might want to somehow
- 0:15use those models to power and document the APIs you're already building with FastAPI.
- 0:21But the popular ORMs, such as SQLAlchemy and others, far predate Pydantic. But could those
- 0:27two things be put together? Sebastian Ramirez is here to tell us the answer is yes. We're
- 0:33covering his project SQL model, which is the marriage between Pydantic and SQLAlchemy.
- 0:37This is Talk Python2Me, episode 353, recorded January 17th, 2022.
- 0:56Welcome to Talk Python2Me, a weekly podcast on Python. This is your host, Michael Kennedy.
- 1:01Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past episodes
- 1:06at talkpython.fm. And follow the show on Twitter via at Talk Python. We've started streaming most of
- 1:12our episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube
- 1:18to get notified about upcoming shows and be part of that episode. This episode is brought to you by
- 1:23datadog and tonic.ai. Please check out what they're both offering during their segments.
- 1:29It really helps support the show. Transcripts for this episode are brought to you by Assembly AI.
- 1:33Their speech to text APIs automatically transcribe and understand audio and video in just a few lines
- 1:39of Python code. Check them out at talkpython.fm/assemblyai.
- 1:45Sebastian, welcome back to Talk Python2Me.
- 1:47Thank you very much. Thank you for inviting me. It's a pleasure to be here again.
- 1:50It's great to have you back. When you were on the show, we were talking about FastAPI,
- 1:54and it seemed like so much had happened. You've done so much, and now there's like all these other
- 1:59frameworks that you've built and all sorts of exciting things, right?
- 2:02Yeah. Very, very exciting stuff. It's like very exciting because Python is getting so excited.
- 2:08Well, it's very exciting. It has always been exciting, but there's so many new things that
- 2:13it's great to build things on top of.
- 2:15It's interesting. I feel like your frameworks, more than many,
- 2:18take advantage of and almost depend upon the latest aspects of Python.
- 2:22Yeah, yeah, absolutely. Like, someone made a meme at some point on Twitter about, like,
- 2:29this guy that was like, pen, pineapple, apple pen. And it was like, type annotations and another
- 2:35library and just put it together. And that's what I'm building. And yeah, it's pretty accurate.
- 2:39Yeah, absolutely. You know, there's, as a community, we sort of muddled our way through the Python 2 to 3
- 2:46transition, and it took a lot longer than even Guido and everyone, many other people expected it to
- 2:52take. But now that we're on the other side of it, stuff like what you're creating and other people are
- 2:57creating, that's what would have been possible had we gone sooner, right? But now it's like,
- 3:03no, everyone's putting their effort into this, these new ideas and these new aspects that are now
- 3:07possible.
- 3:08Yeah, yeah.
- 3:09I think it's great.
- 3:09Yeah, absolutely. And I feel like the way Python is growing and improving is amazing. Like, you know,
- 3:17there are some growing pains, like as with any project or with anything, but like, so like,
- 3:22it's been able to grow in the directions that are needed and to support all the things that's
- 3:27what users are needing. And like, we can do very cool stuff that will not even be possible
- 3:32in other languages. And it's, I don't know, for me, it's pretty exciting.
- 3:35Yeah. It's the same as for me as well. It just gets more exciting. You know, you could see it,
- 3:41you just keep working the same thing. And it just keeps, ah, well, I've been doing that for a long
- 3:44time. I need to change, but I don't feel that way at all. I feel like every day there's something new
- 3:48and amazing and still the possibility for more incredible things to come is certainly out there.
- 3:54I don't feel like we've hit the limit of what it's possible for framework authors like you to build
- 3:59or for the core devs to make Python do, you know, there's the whole performance resurgence thing
- 4:05that Guido Van Rossum and Mark Shannon are doing, that Sam Gill did, that Anthony Shaw is doing,
- 4:11and others. Yeah. I think there's, it's good, right?
- 4:14Yeah. It's amazing. And I feel like the, how the energy between the community and the
- 4:20core developers and like editors and all the tooling, like all growing together and all supporting each
- 4:27other, like helps each other part to grow more and better. And it's so exciting, you know,
- 4:32to get like, for example, like support for very recent things and have been able to use them
- 4:38right away in editors. It's like, oh, so cool. It is absolutely cool. And yeah,
- 4:42the editors are definitely coming along as well. Now, before we get into your latest project,
- 4:47SQL model, which is very exciting, let's just get a quick update on you. You know,
- 4:53you told us the story, how you got into programming Python before, so we're not going to ask you that
- 4:57again, but what have you been up to since you were on the show last? So when I was on the show last,
- 5:01we were talking about FastAPI, right? And the cyber already existed if I'm wrong, right?
- 5:06Yeah. I think that those were the two things you had built and FastAPI was...
- 5:10Okay. Okay. Yeah.
- 5:11Had FastAPI made it to the top three web frameworks yet? I'm not sure if it had, but it was,
- 5:16it was right around that time. Yeah. That's incredible.
- 5:18I think it was very close to that point. That was mind blowing that people were being able to use it so
- 5:25much and adopted so much. And like when it came out, out in the service like that, it was super cool.
- 5:31Yeah. It was, yeah, super exciting. And yeah, like, I don't know, like I have been, you know,
- 5:35like I have been trying to focus, like I have always been trying to focus on whatever is the next
- 5:40thing that I can work on that will have the biggest deep pipe that can the most. And I ended up just like
- 5:47changing areas and like trying to improve different areas and different things. And recently that I was
- 5:52working with the SQL databases, well, or recently, I don't know, some on-sable, that I was working
- 5:58with SQL databases and I was working some of the existing libraries and I wanted to have like all
- 6:02the benefits of the new features of Python, but I wasn't able to have like as much things as I could
- 6:09because most of these libraries were built before we had all these, all these new features.
- 6:14So I wanted to be able to get that. And I figured that the best way to build it was applying the ideas
- 6:20that I had and the learnings that I had from the other tools and from the other things that just like
- 6:24put the thing together because there were some libraries that were trying to do similar things, but like
- 6:30I felt like there was still a bit more that could be done. So yeah, I was just like trying to get that.
- 6:35And that's how we ended up starting.
- 6:37Yeah. Fantastic. Now I feel like SQL model, I don't know for sure I'm asking you, but it seems to me
- 6:43looking in from the outside that SQL model was something you're like, I need a good ORM
- 6:50or FastAPI. And it, the things out there didn't click for you in the way that you wanted it. So
- 6:55you're like, I'm going to build something that fits with this. Right.
- 6:58The good thing with FastAPI is that it doesn't have any need for tightly coupling it with any ORM,
- 7:04with any database. So it can be used with anything, but still there are some, some things that might not
- 7:11be as convenient in the ORM itself. Like if you use it alone. And for example, with FastAPI, then you use it to
- 7:17declare all the data models, all the shapes of the data that you want to receive and you want to send
- 7:22back and to do like all the data validation, documentation, serialization. Then you declare
- 7:26a bunch of those data models with Pydantic. But at the same time, you will end up declaring,
- 7:31duplicating a lot of that information in a separate ORM just to connect to the database and to handle the
- 7:37database and stuff with Python objects. But then you have to duplicate the information in two different ways.
- 7:43And that's what was like, it was not the best developer experience, I guess. And I was trying to
- 7:48make it a bit more user friendly, a bit more developer friendly, I guess, to work with databases and data
- 7:56models and avoid all that duplication information. And at the same time, make it as easy as possible
- 8:02to write a code, just using the same standard type annotations and just using the same, the same
- 8:07intuitive things that we can already use. And that's the point that I was trying to hit.
- 8:12For people to see how that clicks together, I know 12% of the community who builds web APIs and
- 8:18frameworks is using FastAPI, but there's a decent percent out there who maybe haven't heard or
- 8:24looked into FastAPI. Maybe they've heard about it, but they don't know the pieces. Maybe given that
- 8:30that's some of the motivation, maybe give us a sense of how do you build data models that match your APIs
- 8:36and how do you do things like generate the open, the swagger documentation and stuff like that, like
- 8:42set the stage for why just straight SQLAlchemy or some other standard pony ORM or something like that
- 8:49didn't just directly map over to how FastAPI works. Awesome. So like just a very quick intro to FastAPI,
- 8:57it's a web framework that is focused a lot on building web APIs. The main idea is that using
- 9:02the standard type annotations or type hints, so the way that you in a function you declare what is the
- 9:07type of some particular variable, using that same information, that same information by default will
- 9:13give you some certainty that the code is correct and will give you the completion and the inline errors
- 9:18in the edit. FastAPI uses that same information to do data validation of the data that you receive in
- 9:24the web API and to do the serialization of the data that you are returning back and to do automatic
- 9:30documentation. This is all based on a bunch of standards, open API, JSON schema and a bunch of
- 9:35other things. And because it's based on these open standards, then it can generate and it can also
- 9:40provide Swagger UI, as you were saying, which is this web user interface that shows all the information of
- 9:47the API. All the endpoints, where are the data, the shapes that you can send, and you can actually interact
- 9:53with the API directly from the routes without having to go to some documentation site and then update and
- 10:01the wiki gets updated and things like that. Yeah, absolutely. I built a weather service API for one of
- 10:08my courses. This has limited data. People don't try to use this for actual weather service. But it's a
- 10:13FastAPI API. And in addition to all the other cool things it does, like quickly generate the stuff it needs
- 10:19to, you can just go to slash docs and it'll give you the schemas. It'll give you API endpoints, the values
- 10:27that go in, the return value, all of this. I guess the most important aspect of this is probably Pydantic,
- 10:34correct? Yes, absolutely. Like the most important part. You define your stuff in Pydantic models and
- 10:38then that drives so many of these things. Yeah. So FastAPI is built on top of two tools. Pydantic does
- 10:44all the data stuff, data validation, serialization, documentation, and Starlette does all the web stuff.
- 10:49FastAPI just puts them together in a way that they work together. And that's some extra things on top.
- 10:54But Pydantic is the thing that powers all this data validation and all this automatic documentation.
- 10:58Right. Pydantic is so based on the same type annotations, the standard Python type annotations. So you
- 11:03can just like use the same intuition that you will have for a standard Python and they get all these
- 11:08data processing. Yeah. And FastAPI does several things with the Pydantic models. It does model
- 11:17binding, I guess I'll call it. That term's not super common in the Python world, but you can just say
- 11:22my API function or web function takes this model and then FastAPI will like create the Pydantic model and
- 11:31set the values and do the validation. And then also the return value, you can say it will drive this
- 11:36documentation and so on. So the reason I wanted to set the stage so much around Pydantic is that's one of the core
- 11:42elements of SQL model, right? And not just using that library, but so that it can be used as the models in
- 11:50FastAPI, right? Yes, exactly. So SQL model is a library, what they usually call an ORM. And if you don't know
- 11:57what an ORM is, it's just a library to connect SQL database with Python objects and classes. I don't
- 12:04know why we use the term ORM. I feel it's a bit abstract, but it's just a library to connect SQL
- 12:09databases with Python objects and classes. And the thing with SQL model is that it does a lot of work
- 12:17inside so that each model that you create is already a Pydantic model. It's not that it internally uses a
- 12:24Pydantic model or internally creates some additional Pydantic model is that each model is itself a
- 12:30Pydantic model. And at the same time, SQL models is built on top of Pydantic for data processing,
- 12:37validation, all this stuff. And another library that does all the work to communicate with SQL databases,
- 12:42which is called SQLAlchemy. And each one of these models is both Pydantic and SQLAlchemy.
- 12:47Yeah. It's an interesting marriage between Pydantic and SQLAlchemy. Much of the way that you work
- 12:55with it would be very familiar to people who do SQLAlchemy today, right?
- 12:59Yes. That's the idea that it will be very familiar for people that is already working with Pydantic,
- 13:04probably because they are using Plastic BI. But at the same time, it will be very familiar for people
- 13:08working with SQL model because it's just the same look and feel. And it's indeed a strange marriage
- 13:14because these two libraries are so different that getting them to connect and work together in the
- 13:20in the very different ways they are built. It was very, very strange. But they actually ended up like
- 13:25working quite the way. Yeah. I imagine that it was pretty tricky. You know, anytime that you get in
- 13:30the middle of an ORM and its model, I've tried to do that with other frameworks and said, oh, it would
- 13:37be great if I could say use inheritance in this way on my model so that there's not duplication. Like,
- 13:43oh, no, no, no, you can't do that because the thing really depends upon the exact class that
- 13:50derives from its sort of like ORM base class. That's what it uses for its determining what columns are
- 13:57there and so on. Right? Yeah. I mean, it was so crazy. I spent so much time in the
- 14:03the book that we were trying to figure out what was happening underneath and studying so much about
- 14:08like the black magic in Python, the stuff that I always fear, like all the meta classes and stuff
- 14:14and all that weird stuff. I studied so much of that to be able to mix these things together. But,
- 14:19yeah, like because they do things in a very different way. At the same time, that's facilitated,
- 14:25allowing one thing to do its job and the other thing to do its own job in their own particular ways. So,
- 14:33yeah, it was fun. Yeah. Very cool. Whenever I think about an ORM, the thing that I first go to focus on is
- 14:40the Python classes. Because for me, the whole point of the ORM is to let me talk to my database
- 14:49through those classes and model my application through those classes. Right? So let's maybe get
- 14:54started by talking about how do I create a class, a model, a SQL model model here that is both a
- 15:04Pydantic model and a SQLAlchemy-like model. I'm going to talk us through what does it look like?
- 15:09Cool. From SQL model, you will import this class, SQL model. And SQL model, you inherit from this class.
- 15:17You can, for example, create a class hero. And then let's jump to the internal parts of that. Then you
- 15:23will define some attributes for this class hero. For example, you could say that it has an ID,
- 15:28that this ID will be an integer. The way you declare that is with standard Python type annotations.
- 15:34You could say that it has a name and it's a string. If you are familiar with Pydantic, it basically
- 15:38could exactly be a Pydantic model. Yeah.
- 15:41The way you declare your ORM. Yeah.
- 15:42In the simple case, right? Yeah. Yeah, exactly.
- 15:45If it really is just an integer and it just has a number, you don't have to make it auto-increment or
- 15:50any weird stuff like that, right? Exactly. In the simplest cases, it will be,
- 15:54it will look just exactly like a Pydantic model. And in fact, it will be a Pydantic model. And then for
- 16:01some particular cases where you need to add a little bit of extra information to tell SQL
- 16:06model and SQLAlchemy underneath to tell it, "Hey, this does this thing with the database," then you can
- 16:11pass additional parameters and additional configurations. So for example, when you create
- 16:15the ID of this class, this will be the ID of the table and it has to be a primary key. So then you can
- 16:23use the function field to say, "Hey, this still has a default value of none, but I need this particular
- 16:30field or this particular attribute or this particular column, however you want to call it. I need this to
- 16:35be the primary key." And then that information is passed through to SQLAlchemy underneath, which is the one that does all the work.
- 16:43And there's something particularly interesting here is that you are saying, "Hey, this has a default value of none,
- 16:49and that none default value will be used by Pydantic in the Pydantic side of things, but at the same time, it will be
- 16:58used in the SQL side of things. So in the database, this will have also the particular default value.
- 17:04In the case of the primary key, it's just because when you create a model, you still don't know what
- 17:09the primary key is until you say." Most of the time, the database generates that. You could say
- 17:15your primary key could be your email address, but it's common to have it just auto-generated by the
- 17:21database. Yeah. A UUID or auto-increment integer or something like that. Exactly. Yeah.
- 17:26For those cases, you want to have the type annotations very precise so that your code can tell you,
- 17:32"Hey, this could be known at some point." That's just a particular detail. But the thing is,
- 17:37the important thing is that you use standard type annotations to declare attributes, and then these
- 17:42will be mapped to the data model in Pydantic, but at the same time will be mapped to the table in the SQL
- 17:48data. Nice. So it kind of behaves in the two ways. And that means that what you put into your database is pretty much what your API model is as well, right? Exactly.
- 17:58This portion of Talk Python To Me is brought to you by Datadog. Are you having trouble visualizing latency
- 18:06and CPU or memory bottlenecks in your app? Not sure where the issue is coming from or how to solve it?
- 18:11Datadog seamlessly correlates logs and traces at the level of individual requests, allowing you to quickly
- 18:18troubleshoot your Python application. Plus, their continuous profiler allows you to find the most
- 18:22resource consuming parts of your production code all the time at any scale with minimal overhead.
- 18:28Be the hero that got that app back on track at your company. Get started today with a free trial at
- 18:33talkpython.fm/datadog or just click the link in your podcast player's show notes. Get the insight you've been missing with Datadog.
- 18:42That's the idea. Like in the most basic situation, the cool thing is that with this approach and with this tool, you can then create additional models that don't map to one particular table in the database,
- 18:56but are just for handling data with the API. For example, if you create, if you have an API that receives data to create a user, it will probably receive a password from the user. It will have the username and the password.
- 19:08And you want to be able to have that information in the model that you want to receive in the API. But you don't want to save a password as plain text in the database.
- 19:18You don't? Isn't that the easiest way? I get these warnings from these various sites like, oh, your password can't be more than eight characters long because no, yeah, please don't save it in the database. That's a really interesting scenario, right? You need to receive it on one end, but you must not put it into the database.
- 19:34Exactly.
- 19:35You must, it should not carry on.
- 19:37And for example, and then in that same situation, you create the user and you want to return the information of the user back to whatever is the client. You don't want to return the plain text password. You want to say, hey, this is the username, but like, that's it.
- 19:51Yeah. Yeah. Probably not. It's very unlikely that you want to return the hash as well. You just, you don't want it to return at all. Right?
- 19:56Yeah. How do you handle that?
- 19:57Yeah. For these particular cases is where SQL model will shine because you can create one base model that will have like all the base attribute scores.
- 20:05I'm probably will have the name, the last name, the address, the email, blah, blah, blah.
- 20:10And then you can inherit from that model and they have different models for the particular use cases. For example, for creating data. So you will have a plain text password and for returning data, you will have no password at all. But then one of these models will be the actual model that stays in the database. The one that reflects the information in the database. And this one is the one that will have the hash password. But you didn't have to duplicate all the information for the model because they only inherit from the same base model.
- 20:38Is that the section that I got on the screen here that says multiple models with FastAPI?
- 20:42Yes.
- 20:43Like how you do that?
- 20:44Yes, exactly.
- 20:45Yeah. So the idea is obviously you have got some shared information about the user, like the email and their name and stuff. You want to share that probably their ID, but you don't want to, you don't want to share, say there, like you said, the password or whether or not they're an admin on the site or those kinds of things you probably don't want to exchange over the API. Right?
- 21:04Exactly.
- 21:05Exactly. And if you need to duplicate all the information for each one of these particular models, there's a high chance that at some point, whenever you refactor the code, some part will be out of sync. And then you will have a bunch of errors and a bunch of bugs that are very difficult to detect. When you have duplication of code and you have to synchronize it by hand, it makes, it creates a lot of potential bugs that are very difficult to detect.
- 21:31Yeah. So in the way you do your models, this is pretty neat. One of the things that you do is you've got your model hierarchy, you've got SQL model, which is the base class of all the things that interact with, well, SQL model.
- 21:46And those are typically the classes that you create that would be like SQLAlchemy or Django ORM models. But in your world, you can have inheritance. And then somewhere in that hierarchy, you set table equals true as you create the class.
- 22:00So it's not necessarily that just, oh, you derive from this class. So that's a table. It gives you more flexibility and go, this part is a table. That part is a table. Like in the scenario we're talking about, you have a base user where there's a name and a password, a hash password and stuff.
- 22:15No, sorry. You wouldn't want to put that. You would put like your shared stuff into the base class.
- 22:21And then you, right.
- 22:22Name, last name, address, email, I don't know.
- 22:24And then the thing that derives from a user would derive from like user base, which would say like table equals true and it could have its secrets there.
- 22:31Exactly. Exactly.
- 22:32Okay.
- 22:33So that makes a lot of sense. Inbound. What about outbound? So I've got a FastAPI endpoint, right? It could even be Flask or whatever, right? And I've done a query to the database and I get the table version that has the secrets.
- 22:46I can easily go to FastAPI and say the response model is the base thing. So the documentation is right. But if I go to the object I got from the database and I say as dictionary or to dictionary, I forgot exactly what the right term is, but the thing that sends it back, it's going to include everything in it, isn't it?
- 23:03So this is one of those particular details of FastAPI that I think people in many cases miss. And is that in FastAPI, you can say, hey, this is the response model. So this is the model that I want you to use for the data that I'm sending back.
- 23:19So this is the most obvious result of that is that in the automatic documentation, you will get the schema of what is the response data. And that is like the most obvious and visible. But FastAPI will also use that same model to filter out the data.
- 23:34So if you say, if you say the response model is user out, for example, and the class user out, which is a Pydantic class or something like that, this class user out doesn't include the hash password.
- 23:48From the function, you can return an object that includes the hash password or a dictionary that includes the hash password. But FastAPI will omit that field. And FastAPI will only return the particular fields that were defined in the response model that you say that will be returned.
- 24:05Okay. I did not know that that also affected the outbound data, not just the documentation. That's pretty interesting.
- 24:13Yeah. And in fact, that's in many cases, people ask, why does FastAPI use this parameter response model instead of using the return type annotation?
- 24:23Because in Python, when you create a function, you can define what are the types of the parameters that the function receives. And you can also define what is the return of that particular function.
- 24:32If FastAPI use the return value, but then you can say like, hey, the return value is this user out, but then the object that you were returning from that particular function was different object.
- 24:43Then the editor will complain, the tooling and the tools that detect those typing errors like mypy will complain and they will detect, hey, you're saying that you're returning something, but you're returning a completely different thing.
- 24:54So that's the reason why their return type is not what is used to extract that information.
- 24:59And instead it uses this particular configuration responsible because it's used for filtering data.
- 25:05Right. Okay. Interesting.
- 25:06So for people who don't know, haven't seen this in action, you put a decorator like an app dot or API dot get, for example, just like you would say in Flask or something.
- 25:15And you say, here's the URL, but then you also may put response model equals some Pydantic type in FastAPI.
- 25:21And that drives a Swagger documentation.
- 25:24And I am learning now drives the filtering of the allowed return values as well, which is pretty excellent.
- 25:30Yeah. In fact, it will also validate that.
- 25:33So if you are saying, hey, this will return this data and then whatever you're returning doesn't include that.
- 25:39That will actually be an error on the server because you are saying that the contract is that I will return this data, but then suddenly you are not returning it.
- 25:47Then it will raise an error inside of the server and it will tell you, hey, the data that you're sending is incorrect.
- 25:52So there's something going on here.
- 25:54There's something wrong with your code because you're sending something invalid from what you say that you were going to send.
- 26:00That's pretty fantastic.
- 26:01Okay. I didn't realize it made such great use of that response model.
- 26:05So that's just a whole nother level to bringing Pydantic into that world.
- 26:09So there's a bunch of comments and thoughts here in the audience.
- 26:13So I kind of want to bring some of them in because there's a bunch of great ones.
- 26:16First of all, former guest Waylon says your mustache is fabulous, which is always required when you're on a video.
- 26:22Thank you very much.
- 26:24Sveta Link says big like on FastAPI.
- 26:27I think FastAPI is absolutely a good thing.
- 26:30Hey, thank you.
- 26:30And Jacqueline also very much.
- 26:33Poplin says, I have a question.
- 26:35If the data schema is complex and has nested JSON structure, in what case would you validate?
- 26:41Like it's pretty straightforward to just nest the Pydantic, but this brings us, you know,
- 26:47if you're going to be in a world where you're nesting Pydantic things, you may want to save them to the database.
- 26:52What's the story on relationships?
- 26:55And this basically, I've received some data that is like nested related data.
- 27:00What do I do in SQL model?
- 27:01So if you need to receive some complex data structure and you need to extract the information,
- 27:07you can declare, you can declare models with Pydantic or with SQLAlchemy, sorry, with SQL model,
- 27:13say that, hey, this is just a data model.
- 27:15And then you can manually extract the sub components and then just add them to the database independently or something like that.
- 27:21There wouldn't be a straightforward way to say like, hey, I received this giant JSON and automatically generate a bunch of different models that don't exist yet or something like that.
- 27:31Or to automatically infer where to put each information.
- 27:34It will be as straightforward.
- 27:36Like it will have a lot of different design possibilities.
- 27:40So it will be easy to get it drawn.
- 27:42So the way that you will do it is that you define the complex data shape that you want to receive.
- 27:48And then once you take it, you just extract it, each part of the information and each particular object or each particular data point that you want to then say to the database.
- 27:59Now, to return data to the user, with SQL model, you can have relationships and relationships between different tables,
- 28:08have like automatic joins and all that stuff.
- 28:10This is all thanks again to SQLAlchemy, which is the thing that works underneath.
- 28:14It already models that, yeah.
- 28:16Yeah, exactly.
- 28:16But then you can use that information and you can just like declare the models.
- 28:20And this again works well with this idea of having narratives to be able to declare, hey, I want to return this model and I want it to include this particular relationship model.
- 28:31So it will include the information from other tables.
- 28:34We will just extract that information and return it to the client.
- 28:37That's really cool.
- 28:37What about lazy loading?
- 28:40I'll ask this in two aspects.
- 28:42If I've got a relationship, I can do a join or a subquery load on it in SQLAlchemy so that if I know I'm going to be traversing that relationship,
- 28:52I don't end up with the dreaded N plus one performance problem where I thought I was doing one query and I'm doing 51 queries.
- 28:58If I got a, you know, 51 or 50 results back, something like that.
- 29:02Is that support flow through SQL model as well?
- 29:05The joins?
- 29:06Yeah.
- 29:06So the thing is that SQL load actually just like exposes the same interface as SQLAlchemy because it's actually just using SQLAlchemy underneath.
- 29:15And SQLAlchemy supports everything, including like lazy loading.
- 29:19SQLAlchemy actually supports things that are not supported by many other ORMs.
- 29:23I forgot the name.
- 29:24Having primary keys that are composed of different, of several columns.
- 29:28Things like that.
- 29:29Composite indexes and composite keys.
- 29:31Composite keys.
- 29:32Yeah.
- 29:32There's a bunch of things that SQLAlchemy supports.
- 29:35If SQLAlchemy supports them, then the SQL model automatically supports them because SQL model is just generated directly from SQLAlchemy.
- 29:43Yeah, that's really cool.
- 29:44Now, the question I was thinking about is if I have a result from the database that has relationships, a relationship, and I return it from a FastAPI endpoint, is that going to go and start iterating the relationship?
- 29:59Do I need to be worried about N plus one problems by returning these models that then are getting serialized in eager ways?
- 30:08Yeah.
- 30:09You know, where it's like tracing through all the relationships so it can build the whole JSON to get it back out.
- 30:14And then return the whole database in a single JSON.
- 30:16Wow, that took a while.
- 30:18That was slow.
- 30:18That would be so painful.
- 30:19Yeah.
- 30:20No, by default, FastAPI and SQL model won't include relationships in models, won't include them in the data that is returned back.
- 30:30But if you need to include some of those, you can declare, again, using inheritance, you can declare a different model that defines, hey, this relationship, this particular attribute, this should be included.
- 30:41That way you can define that particular one in the specific endpoints that you want to include the information in the resulting value.
- 30:48Right, okay.
- 30:49That will work to force SQL model and to force, well, FastAPI and SQL model to do all the N plus one queries and to just extract information and send it back.
- 31:00But if you are returning that data including the relationships, you will probably want to eagerly load that information, which is something that is supported by SQL model and by SQL.
- 31:12So you will load the information that you need including the relationships and then you just return that object directly and you define the model.
- 31:19Hey, I want this to include the relationships.
- 31:21So it will just like include the information that is already there.
- 31:23I can see that this N plus one issue is without the join or eagerly load is happening through a profiler.
- 31:31If I was doing this in something like Django or Pyramid, I could look into the debug toolbar and it'll actually show me the SQLAlchemy statements that are running.
- 31:41It'll be like, why are there 50 queries on this page?
- 31:44It's harder, I suspect, in FastAPI, especially if it's operating in API mode where it doesn't have like debug toolbars and stuff like that.
- 31:52Probably one way you could see it is to say echo equals true on the engine.
- 31:56Yeah, exactly.
- 31:57Exactly.
- 31:58Because FastAPI is not integrated with any database and SQL just makes it super easy to work with FastAPI, but SQL could be used with any other framework.
- 32:09That was the intention.
- 32:09SQL model doesn't depend on FastAPI and FastAPI doesn't depend on SQL.
- 32:13So you just integrate very well.
- 32:14But then you could just enable the table thing with SQLAlchemy that will then show all the particular SQL statements and show you, hey, this is what is running.
- 32:24This is what is happening.
- 32:24Right.
- 32:25Yeah.
- 32:25So if you're connecting to the database, then this is a SQLAlchemy thing, but obviously it'll flow through.
- 32:32Right.
- 32:32You just say when you create the engine, you give it the connection string, you can say echo equals true.
- 32:37And if you are doing queries that are doing a bunch of indirect behind the scene, lazy queries for you, your console window, your terminal, whatever is just going to blow up with a query.
- 32:48You're like, why is so much SQL screaming by, right?
- 32:51Yeah, exactly.
- 32:51Exactly.
- 32:52Exactly.
- 32:52That's what it will work.
- 32:53Let's talk about editor support really quick.
- 32:55So one of the things that's really nice about Pydantic is it requires you to state the types, whether those are fundamental types, whether those are nullable types, like optional of int, or they're nested types, like a user contains an address Pydantic model.
- 33:13All of those scenarios result in really good editor support, right?
- 33:17Yeah.
- 33:18Yeah, exactly.
- 33:19And what's the story for editors in SQL model?
- 33:21That's something you specifically call out about how it has good support there.
- 33:24So if you check the source code for SQL model, it's actually super short, but it's just like a bunch of a lot of tricks together.
- 33:32And many of those tricks are actually about type annotations because the thing that allows your editor to provide the auto-completion and the inline errors are the declarations of these types, the type annotations or type hits.
- 33:46And SQL model does a lot of internal work so that whenever you use any part of SQL model, you will get that type information in your editor.
- 33:56For example, if you query some model, query some table to get information, to get data from the database, the result that you get back, the object that you get back, will have internally all that type information so that the editor will be able to provide you with all the autocoption and all the inline errors and all those things.
- 34:16SQL model, in fact, sacrifices some of the more advanced or obscure or sophisticated use cases that SQLAlchemy supports and sacrifices those to instead get very good autocompletion and inline errors everywhere in the code.
- 34:33And this is another thing that the results and clear in SQL model is that it uses some draft standards that are not even implemented yet.
- 34:43I don't know, I don't know, I'm not part of the standards, official standards yet, but they are already supported by some editors.
- 34:51For example, Visual Studio Code already supports providing autocompletion when you are creating a new instance of a particular class or for the particular class of a model.
- 35:00Having this autocompletion is not very easy to do with other tools because the editor doesn't have any information about what are the parameters that you can pass, what are the arguments that you can pass?
- 35:11Right.
- 35:12When you create a Pydantic model, it doesn't in anywhere indicate here is the constructor or initializer and here are the keyword arguments that happen to be all the static values.
- 35:24It will just say like keyword arguments or like data, star, star, something like that.
- 35:29Yeah.
- 35:30But I always think thanks for nothing when I see that.
- 35:32Yeah, exactly.
- 35:34But actually Pydantic 1.9 includes this same trick.
- 35:38So now you get autocompletion in Visual Studio Code.
- 35:41In PyCharm, you already have autocompletion with Pydantic because they have a plugin for Pydantic to provide autocompletion for those things.
- 35:49But it requires this particular plugin.
- 35:51Now with this extension, you can get also autocompletion in VS Code.
- 35:55And with the same extension without needing any plugin, you get autocompletion for SQL model in Visual Studio Code.
- 36:01I think the people from PyCharm were also taking out to maybe support the same standard, which will allow PyCharm to provide automatic autocompletion for SQL model and other libraries like Pydantic and Attrs and others.
- 36:16Yeah, that's great.
- 36:17Definitely the widespread use of Pydantic effectively is forcing everyone to go like, all right, how can we make this work better on the creation side?
- 36:27So RJL out there has a comment, which then leads me to an interesting question.
- 36:33Says, I'm old fashioned.
- 36:34I use direct SQL statements.
- 36:36No ORM.
- 36:37I really need to take the time to go down this route.
- 36:38Indeed, I do think so.
- 36:40It's certainly worthwhile.
- 36:42What are your thoughts on using straight SQL versus not?
- 36:45Then I'll ask my question.
- 36:46So I think, you know, like it just, it's a lot about taste and how people prefer to code.
- 36:52There's a lot of people that are so comfortable with SQL and that can do so many things with SQL very easily that it's just more efficient to just use SQL directly.
- 37:02For me, some of the advantages with ORMs is that I get inline errors that I get autocompletion for what is the name of the attribute.
- 37:10If I forget that I say secret underscore name, the editor will autocomplete that for me.
- 37:15But if I'm typing that inside of just a long string in Python using SQL, then I have to remember because no one will tell me that I have a syntax error in my SQL or that I'm using an attribute that doesn't exist.
- 37:27One of the things that actually blew my mind is PyCharm.
- 37:30If you set it up to, if you basically connect the database to your project, it'll give you autocomplete and error checking inside strings inside Python.
- 37:40That's super cool.
- 37:41For your schema, which is amazing.
- 37:44That said, I never do that because to me, one of the things that is super valuable, one is this autocomplete.
- 37:49The other is refactoring as well.
- 37:52Like, oh, did we change the name of that?
- 37:54Well, oh, there was that one query we didn't update and now it crashes in production, but only sometimes when it hits this case.
- 38:01And, you know, it's just the way it sticks together and stays consistent to me seems a lot stronger if you're using models as well.
- 38:08Yeah, absolutely.
- 38:08And also the ability to swap backends, right?
- 38:10The way you do parameterized queries is different across different database backends.
- 38:15Yeah.
- 38:15Also, if you write SQL by hand, then you have to be super careful and probably you have to be a SQL wizard and, like, know how to sanitize all the data that you're putting or, like, you know, otherwise you could end up in nasty situations.
- 38:29But, like, I'm saying that there's a lot of people that prefer, really prefer writing SQL directly.
- 38:36You know, like, the same author of Pydantic, which SQL model is based on, prefers to write SQL directly.
- 38:42And, like, he's using FastAPI and everything, but he's just more comfortable to me.
- 38:46And the author of PyPy, PsychoPG, the driver for PostgreSQL, he just uses SQL directly.
- 38:55It's just, like, more comfortable for him.
- 38:57He uses FastAPI a lot, but still, like, it's just more comfortable.
- 39:00So I guess, like, it depends a lot.
- 39:02For me, I depend a lot on the tooling and editor support and refactoring, as you were saying.
- 39:08Like, if I change a name, I know that it's changed everywhere because I won't remember.
- 39:13I won't remember.
- 39:14Well, did I make this mistake?
- 39:15Yeah.
- 39:16Yeah, absolutely.
- 39:17Martin in the audience asked an interesting question.
- 39:19Down here is a better example.
- 39:21One of the challenges of ORMs is to make set-based operations apply back to the database.
- 39:28Like, I want to change this field.
- 39:31Like, I want to set a is on sale flag to true for all products where the price is less than $10.
- 39:38Right?
- 39:39Where I'm not going to pull.
- 39:40I don't want to go, let me query all products whose price are less than $10.
- 39:44Change it on the object and then push those changes.
- 39:47I want to push the...
- 39:48I just want to say, update where this set that.
- 39:51You know what I mean?
- 39:52Yeah, yeah.
- 39:52What's the story about that with SQL model?
- 39:55Because that's one of the things that can really just hammer productivity or speed, I guess,
- 39:59is if you've got to, like, pull back a whole bunch of stuff to just make sort of consistent
- 40:04changes across them.
- 40:05You know what I'm saying?
- 40:05Yeah, yeah.
- 40:06Like, this is one of the use cases where you will want to interact directly with SQLAlchemy.
- 40:11And you can do that through SQL model, but you can't write, like, where it's as complex
- 40:16as you want through SQL model, but, like, just using pure SQLAlchemy underneath.
- 40:21And, like, you can use, like, very advanced things with SQLAlchemy.
- 40:25SQL model focuses a lot on, like, the simplest and most common use cases, providing, like,
- 40:32the best developer experience.
- 40:34You know, like, certainty that the code is as ever free as possible because you have all
- 40:39these type annotations and all these type checks.
- 40:41But for any case that is a little bit more advanced, you can just, like, drop down directly
- 40:46to SQLAlchemy.
- 40:47And because SQL model is just pure SQLAlchemy, the models are themselves.
- 40:51Just SQLAlchemy.
- 40:52So you can just, like, use SQLAlchemy directly.
- 40:54In fact, you could use one of these models with a SQLAlchemy engine directly, and it would
- 41:00work.
- 41:00Okay.
- 41:01Sky points out in the audience that you were too humble to call out the PR that got that
- 41:06autocomplete for VS Code was actually by Tandic.
- 41:09It was by you.
- 41:10So well done.
- 41:10Thank you.
- 41:11Keep moving it forward on both fronts.
- 41:13So what about performance?
- 41:15There's extra goodness in the validation and the type conversions and stuff like that of,
- 41:22say, Pydantic.
- 41:22But is there a large overhead for using this, say, over SQLAlchemy over, say, raw SQL?
- 41:29Yeah, well, so when you use, when you declare a model and you say, hey, this is table model,
- 41:35so this is, like, the equivalent of a SQLAlchemy model, then a lot of the validation and that
- 41:40stuff with Pydantic is a very written.
- 41:42So when you create a model, it will not be validated on creation for that particular table
- 41:47because this will be handled directly by SQLAlchemy.
- 41:50And for example, with SQLAlchemy, you can create an instance of a model without setting
- 41:56all the attributes and then you can set the attributes manually afterwards.
- 41:59If Pydantic was doing validation for that, like, that will explode and that will say, hey,
- 42:04this is invalid.
- 42:04Yeah.
- 42:04So when you are working with SQLAlchemy alone, well, like, with the SQL parts alone through
- 42:09SQL model, then it's just, like, using SQLAlchemy.
- 42:11Okay, so it's not really any different in terms of, like, whatever SQLAlchemy does, this
- 42:17does in terms of performance.
- 42:18Exactly, exactly.
- 42:19It just has, like, and actually, the code is so, so sleek, it's so little that, like, whatever
- 42:24is the overhead will be, I will think it will be negligible.
- 42:27At the same time, I'm not optimizing for, like, squeezing the maximum performance, but
- 42:33for getting the maximum correctness in the code and the best developer experience.
- 42:38Because I feel it helps a lot more to be a lot, as a developer, building the tool and making
- 42:45sure that it's all correct, than having the code super fast, but very difficult to debug and
- 42:49to understand and to write correctly.
- 42:51Okay, so I guess you just got to decide, like, is an ORM the right fit at all?
- 42:56Yeah.
- 42:56And if it is, then this is a pretty good choice if you like this API.
- 42:59Yeah, absolutely.
- 43:00If you were needing, like, the maximum performance that you can get, you will probably end up
- 43:05just, like, getting an async, an async drive it directly and just, like, writing SQL directly
- 43:10for the particular endpoint that needs this extra boosting performance.
- 43:14But for most of the other cases, this will probably help making sure that the code is
- 43:18correct and making sure that you can write quickly and, like, be done with the feature
- 43:23that you're implementing quickly.
- 43:26This portion of Talk By The Nome is brought to you by Tonic.ai.
- 43:29Creating quality test data for developers is a complex, never-ending chore that eats in the
- 43:35valuable engineering resources.
- 43:36Random data doesn't do it.
- 43:38And production data is not safe or legal for developers to use.
- 43:42What if you could mimic your entire production database to create a realistic data set with
- 43:47zero sensitive data?
- 43:50Tonic.ai does exactly that.
- 43:52With Tonic, you can generate fake data that looks, acts, and behaves like production data
- 43:58because it's made from production data.
- 44:00Using their universal data connectors and a flexible API, Tonic integrates seamlessly into
- 44:06your existing pipelines and allows you to shape and size your data to scale, realism, and degree
- 44:11of privacy that you need.
- 44:13Their platform offers advanced subsetting, secure de-identification, and ML-driven data synthesis
- 44:20to create targeted test data for all your pre-production environments.
- 44:24Your newly mimicked data sets are safe to share with developers, QA, data scientists, and, heck,
- 44:30even distributed teams around the world.
- 44:32Shorten development cycles, eliminate the need for cumbersome data pipeline work, and mathematically
- 44:38guarantee the privacy of your data with Tonic.ai.
- 44:41Check out their service right now at talkpython.fm/tonic, or just click the link in your
- 44:47podcast player's show notes.
- 44:49Be sure to use our link, talkpython.fm/tonic, so they know you heard about them from
- 44:54us.
- 44:55I've got one more thing I want to talk to you about.
- 45:02One of the things, though, that you spoke about is the ability of having, and this is just
- 45:13generally true for SQLAlchemy.
- 45:16These models, they're tied back to what's called a session or a unit of work to do with the database,
- 45:22and you can't do a query, get a record, and then go from a separate situation and try to jam it back.
- 45:29It's got to be stuck to the session that it comes from, right?
- 45:33So you don't share the models across sessions, but one of the things that would be nice is just to have a single one.
- 45:38And so FastAPI has a dependency injection system that you talked about can be used for basically always providing one and only one session to an API endpoint or a web endpoint that then could be the database management.
- 45:56Like creating a unit of work that is the lifetime of the request, basically.
- 45:59Want to talk about that?
- 46:00Yeah, exactly.
- 46:01I think you described it perfectly.
- 46:03I don't know what else can I yell at the bullets, right?
- 46:05So this dependency injection system is just like you declare some function and FastAPI will make sure to run that function and provide the value to all the things that need that value for one particular request.
- 46:17Right.
- 46:18This has nothing to do with the database, by the way.
- 46:20This could be anything.
- 46:20It could be a login framework, whatever, right?
- 46:22Exactly.
- 46:23So this is very useful for doing logging, for doing authentication, for doing authorization with roles and whatnot, for doing logging or setting up things that load stuff to remote servers like Sentry or like Datalog or I don't know, for all those things that you need to do.
- 46:40And that can be, and that is, there is some logic that needs to be shared and that could run before the request is handled and maybe after the request is done.
- 46:48And then you can share this information.
- 46:50So in many frameworks, there's a concept of a middleware, which is something that runs before the request and after the request.
- 46:56But then you have to run this thing for every request.
- 46:59With dependencies, with this dependency injection system, you can define exactly where you want it to run.
- 47:04And you can define, I want this to be run with a group of endpoints or with a group of path operations, as I used to call them, for just one particular endpoint or for a bunch of endpoints.
- 47:14And with this system, you can extract and you can generate whatever it is that you need to generate for the particular request.
- 47:21And the good thing about the dependency injection system is that if you're extracting information from the request, for example, from a header, then this information will be also extracted and included with past API and with all the open API and all these standards.
- 47:34So you will get that information in the automatically generated user interface to explore the API.
- 47:40Yeah.
- 47:40Very cool.
- 47:41So what steps do I have to take to do dependency injection to get that session to show up?
- 47:47I remember you had it in the documentation, but I don't remember where it is right now.
- 47:51I think for the particular case of SQL model, even though FastAPI and SQL model are independent, are made to be very compatible with that independent.
- 48:01I have a lot of documentation about writing applications with FastAPI and SQL model in the SQL model docs.
- 48:08The way that you will handle a FastAPI dependency in general is that from FastAPI, you import this special function depends.
- 48:17And then you create some function that will return sole value.
- 48:21This function will have the same style as any other function that handles a particular request.
- 48:26So it can have some parameters with some types and that information will be extracted from the request.
- 48:32And it just returns something.
- 48:33This is just plain old function.
- 48:35And then you pass function is this is what will be the dependence.
- 48:39Then you pass that function as a parameter to depends.
- 48:42And then you put depends as the default value of sole parameter in your main function that is handling the request.
- 48:50I see.
- 48:50So you could say session equals like depends.
- 48:53Here's some function that will get called to create the session.
- 48:56Session equals depends and calling depends with the function that is named get session or something like that.
- 49:02Do you have a way to see both sides of that?
- 49:05With dependency injection.
- 49:06So does it just return the value or can you like create a session and then yield the value and then keep processing or something along those lines?
- 49:13Exactly like that.
- 49:14Okay.
- 49:14You can create a session that you can yield the value.
- 49:17And then after the request is done, you can continue doing more stuff after yielding that particular session.
- 49:24So you can create a session, give the session from the dependency, and then the main code that will handle the request will have that session.
- 49:31And then the same dependency can take care of closing the session after the request is done.
- 49:36Exactly.
- 49:36Try, yield the session, finally close it.
- 49:40Maybe like if there's no exception, commit it, something like that.
- 49:43Exactly.
- 49:43Okay.
- 49:43That's pretty flexible.
- 49:44Yeah.
- 49:45And in the main code that you have, you don't have to take care about creating the session or closing it or making sure that there are no exceptions because you can do all that stuff in the dependency and share that logic throughout your code.
- 49:58And the other thing is that dependencies can themselves depend on other dependencies.
- 50:03So you can create a dependency that gets the session for the database, and then you can use that in another dependency that gets the current user and extracts from the header or from the authentication token or whatever, extract the user ID, then gets the user ID from the database and then returns the current user.
- 50:21So that you have a whole dependency that just takes care of returning the current user and making sure that it's authenticated.
- 50:27And then in all your, and you can reuse that code in all your endpoints or in all the main functions that handle the requests.
- 50:34And all those functions will be able to just get the current user right away without having to have all the logic to extract the information, process the token, all the stuff.
- 50:43Sure.
- 50:44This is very neat.
- 50:45I haven't used this enough during my work with FastAPI, so I got to check this out.
- 50:49All right.
- 50:50Now, let's do a bit of a lightning round here of the Twitter questions, because I've seen some of these questions come up in the live chat, but I also think I pulled out these ones that I thought people put on Twitter that were pretty good.
- 51:01LeMatte Webster says, any plans to ramp or replace Alembic to make migrations more developer friendly?
- 51:08So first of all, migrations, you've got to keep your database in sync with your models.
- 51:13Otherwise, SQLAlchemy and hence SQL Model will freak out about that because it's going to be a problem.
- 51:19But Alembic is, while it works, is a little bit hard to say, like, here's all the models you need to pay attention to.
- 51:25And here's the scenario where you run.
- 51:26It's a little bit clunky.
- 51:28It works well, but it's not super smooth.
- 51:30And I think that's what Matt's asking here.
- 51:32Alembic is the official tool from SQLAlchemy to do the migrations.
- 51:36And because SQL Model is itself also just SQLAlchemy underneath, Alembic works with it perfectly.
- 51:42Alembic is a great tool.
- 51:44It's super advanced and helps a lot.
- 51:47It can even generate automatic migrations and things like that.
- 51:50I think the main problem with Alembic is that in some cases it's not as intuitive.
- 51:55So, yes, what I want to do at some point is to wrap a bit of Alembic.
- 51:59I will replace it because it's already doing a magnificent job.
- 52:03But, and it will be super difficult to write all that logic and all that work that Mike has been doing for a very long time with SQL Model and Alembic.
- 52:12I will wrap it and I will try to add a bit more of documentation to explain how to handle the simplest cases, which is the same that I'm doing with SQL Model.
- 52:20If you need something more confidence, that will probably just go Alembic directly or to SQLAlchemy directly.
- 52:25Related to this, not Twitter question, Michael question, do you have any thoughts about testing code using these models and stuff like fake data or mocking out the database beyond just the standard stuff you would do to SQLAlchemy?
- 52:39Like, is there anything special about SQL Model that makes testing it easier or different than SQLAlchemy?
- 52:44No, the testing will be pretty similar to SQLAlchemy.
- 52:47Pretty similar.
- 52:47Yes, I just have like a bunch of documentation of how to do testing and even how to do testing with FastAPI applications using SQLAlchemy and how to, for example, use SQL Lite database or testing that will be run on memory instead of the production database that will be a PostgreSQL or MySQL or whatever.
- 53:05Just change the connection string to the engine and let it go.
- 53:08Yeah, okay.
- 53:09And then make it run with a database in memory and then make it work correctly with threads and everything.
- 53:14So something like a pytest fixture that initializes the database, but you just use colon memory colon for the connection string so that it just goes away.
- 53:23Yes, exactly like that.
- 53:24It's documented exactly like that.
- 53:26All right, right on.
- 53:27All right.
- 53:28Ricky Lim says, would SQL Model be part of, should, could be part of the standard Python library?
- 53:34I have some thoughts on this, but I want to hear your thoughts first.
- 53:36I have some historical perspective on this, but I want to hear your thoughts on this.
- 53:39Okay, so it will not be part of the standard library.
- 53:42Ideally, it will not be part of the standard library because if it was part of the standard library, it will mean that it will be available in Python 3.13 or something.
- 53:53And the users of Python 3.10 right now will not be able to use it on one side.
- 53:59On the other side, having more stuff in the Python standard library adds more inconvenience and more burden to the core maintainers, to the core developers, Python, which makes it even more difficult for them to continue supporting Python and all the different versions.
- 54:14And it will also complicate things for Red Cannon that is trying to figure out a way to slim down Python so that you can, for example, run it directly on the web browser.
- 54:26Right.
- 54:26Right.
- 54:27How do we build it in WebAssembly?
- 54:28This doesn't help.
- 54:28Yes, WebAssembly.
- 54:29And you know, Red Cannon and Kristen Hanks have been doing like a very cool job.
- 54:33It's very exciting.
- 54:34A lot of that will probably require actually is leaning down a bit.
- 54:38Standard library.
- 54:39As far as I understand, but I'm not no expert.
- 54:41Yeah, I imagine a world where we have, I don't know what the right word for it is, but there's like a standard cross environment Python minimum set of language features of standard library where things like, you know, stuff that talks on the network or does UI things or whatever.
- 55:02We're just, that is not part of this like minimum subset of Python that we're guaranteed to have so that we can put it on WebAssembly.
- 55:10We can put it on mobile devices.
- 55:12We can put it on servers.
- 55:13And as long as you program to this minimum set, your place where your Python can exist is broader, you know, like MicroPython potentially.
- 55:20I think that that's the trend and not the trend towards putting more stuff there.
- 55:24Yeah, exactly.
- 55:25Absolutely.
- 55:26Absolutely.
- 55:27And it's fun that it's already happening.
- 55:29MicroPython is already that.
- 55:31It's just that it cannot say it's a standard Python because it has to link that a bunch of things.
- 55:35But being able to have a microcontroller and write code in Python that is running the microcontroller, that's amazing.
- 55:42That's mind blowing.
- 55:43Yeah, the most mind blowing thing for me is that you can hook a Lambda expression directly to a hardware interrupt.
- 55:51That is like, what?
- 55:53You can do what?
- 55:54That's amazing.
- 55:55The historical perspective that I want to bring up here is I believe the core developers actually considered this for requests.
- 56:01And they decided that, no, they're not going to put requests in the standard library to replace URL lib because it would limit requests' ability to grow.
- 56:10Like, changes could only come once a year.
- 56:12It couldn't come three times a week if there was important changes, right?
- 56:16Like, the speed of development would be hindered.
- 56:19So they said, you know what?
- 56:20No, we don't want to.
- 56:21Yeah.
- 56:21Plains to tell us.
- 56:21Yep.
- 56:22All right.
- 56:22Next, Dimitri Figo says, are you considering working on generating TypeScript declaration files based on what's defined on the FastAPI backend?
- 56:33That was that documentation I showed where it has the schema and all that and, like, the endpoints.
- 56:37Yeah.
- 56:37To make it, to explain it a little more, when you go to the automatic interactive documentation for the API, that is all based on this standard schema of the API called OpenABI.
- 56:49This is just a huge JSON that defines all the data shapes that you're using, all the endpoints, everything.
- 56:54But that same thing, because it's a standard, then you can use that same thing to generate code for clients that communicate with your backend.
- 57:02And in fact, there's a bunch of client generators for many languages, including TypeScript.
- 57:06And I have used them.
- 57:07I have used some of them.
- 57:08And they are actually very, very good.
- 57:10Like, you can achieve things like defining in the backend where the data shapes that you're using.
- 57:16Then you update something.
- 57:18And then you regenerate the client in the frontend.
- 57:20And now, after that, the frontend team will be able to have access to this new API endpoint with autocompletion in their editor and everything.
- 57:29It works very well.
- 57:31It's super exciting.
- 57:32I just haven't had the time to document, like, the whole recipe to make it work.
- 57:37But it's already there.
- 57:38It's already working.
- 57:39And it already does a great job.
- 57:41Yeah.
- 57:41Maybe somebody wanted to contribute a PR or do some help there.
- 57:45They could, right?
- 57:46Yeah.
- 57:46You know, like, even a blog post will just, like, that will be a lot faster to get out.
- 57:52And that will help a lot.
- 57:53And a lot of people.
- 57:54Indeed.
- 57:55Zach Kud says, I'd love to hear how you approach figuring out the integration with SQLAlchemy.
- 58:00I mean, we talked a bit about this.
- 58:02But any other lessons you've learned from basically getting in the middle of SQLAlchemy and all of that it does?
- 58:08Yeah.
- 58:09It's very interesting that SQLAlchemy was created at a time where, like, it was, I don't know, Python 2.something.
- 58:17There were no context managers.
- 58:19So that thing that you do with a blog that you say with something, something, as blah, blah, blah.
- 58:25And then inside of that report code, that was not available, but that didn't exist.
- 58:30SQLAlchemy was made before that.
- 58:32So SQLAlchemy had to do a lot of sophisticated tricks to make everything work.
- 58:37And then getting down inside of it and trying to understand a lot of things like, why is this thing doing this?
- 58:44I'm working like this.
- 58:46And it's because of those things.
- 58:47I think I ended up learning a lot about those little details and a lot about how classes work internally and how a class is an instance of what and all those things and how you can configure all that.
- 58:59But the idea with SQL World is to make it super easy for you to use it without having to deal with all the internal complexity.
- 59:07Because it's crazy.
- 59:08You don't have to know.
- 59:09Only you had to know and go through it.
- 59:11So I think it's worth pointing out, I did have Mike Bayer on the show recently to talk about SQLAlchemy 2.0 and how they're moving to have basically the client side view of that be everything as a context manager and sort of change that up a bit.
- 59:26So how close is this to the 2.0 model or is it the 1.0 model API?
- 59:31Yeah.
- 59:31So Mike Bayer did a lot of work to make the compatibility transition as easy as possible.
- 59:37And SQLAlchemy, the latest available version, which is 1.4, is compatible with the previous style and with the new style.
- 59:45So code that is written with the new style will be compatible with SQLAlchemy 2.0 whatever and above.
- 59:51SQL model is based on this new style.
- 59:54So if you, for example, if you have an old application with SQLAlchemy, the first thing that you will want to do is to migrate to SQLAlchemy 1.4 and make sure that it's compatible with the new style.
- 1:00:05And make sure that you don't have any warnings.
- 1:00:07That's the main thing that you will do to make sure that it's compatible.
- 1:00:09And then after that, you can migrate to SQL more.
- 1:00:12The migration is also super simple.
- 1:00:14It's just like changing some classes for type annotations.
- 1:00:17Yeah.
- 1:00:17Absolutely.
- 1:00:18There was a question.
- 1:00:21Yeah.
- 1:00:22So the question by Python at night was, what would the level of effort or benefit, if any, of converting SQLAlchemy models and schemas to SQL model?
- 1:00:31Sounds like the effort is small and the benefit is all the features we spoke about, right?
- 1:00:36Yeah.
- 1:00:36Yeah.
- 1:00:37Okay.
- 1:00:38Would you recommend it?
- 1:00:40I mean, people are using SQLAlchemy.
- 1:00:42They're like, you know, I'd really would like to have some of that Pydantic magic.
- 1:00:45When would you say, okay, the trouble of making a change is sufficient?
- 1:00:50So if it was me, I would just use it right away.
- 1:00:53Right now, it's in version 0.0 point something.
- 1:00:56I will release 0.1 point 0 once I have 100% of test coverage.
- 1:01:01Right now it's 97% just because I'm not freaked out of that.
- 1:01:05But like most of it should already work.
- 1:01:07It's actually very simple.
- 1:01:09And if anything, the work that it does is actually very small because all their needs is all done by SQLAlchemy.
- 1:01:17If anything went wrong, you could also just like switch back to SQLAlchemy directly.
- 1:01:22It's just that you will lose the benefits.
- 1:01:24Right.
- 1:01:24Basically change your class back to driving from SQLAlchemy based and you're good to go.
- 1:01:29Yeah.
- 1:01:29Okay.
- 1:01:29The benefit that you will get is auto-completion and inline errors everywhere where you are using these classes that you will normally not get.
- 1:01:37And the integration with response model.
- 1:01:39And the integration, yes, of course, integration with response model is that, yeah, actually that's a lot of code that you will save if you can share that with Pydantic and with SQL Mode.
- 1:01:47Just make sure that you follow all the information about how to pin and how to upgrade versions because it's very detailed how you should go about that.
- 1:01:57Because as things are still changing and as it still has like a little bit of extra testing to do, you should be careful about how to pin.
- 1:02:05Just not install like whatever version comes.
- 1:02:08Just make sure that you've been the right version.
- 1:02:10You have tests and then when you upgrade, you make sure that the tests are pausing and then you can upgrade the version.
- 1:02:16Yeah.
- 1:02:16Good advice.
- 1:02:17Already talked about that one.
- 1:02:19So Lado asks, are you going to stretch modern Python conventions from the backend part, which you already did?
- 1:02:26We talked about like using the types and stuff for model binding to Python challenging front end as well.
- 1:02:35Should we expect something like Reactipy, like React, but in Python?
- 1:02:39That will be it.
- 1:02:40Do you care about the front end in the sense that you have any intention to build stuff for it?
- 1:02:45Yes, I care a lot from then and I have actually, I think I started in that and I have worked with Angular, React, Vue.js and like all the stuff.
- 1:02:53I think it will be amazing to be able to write Python in, to write Python for front end.
- 1:02:58But if someone is going to make that happen at some point, they'll probably let Connor and Christine Haynes making WebOssently work for Python.
- 1:03:05Yes.
- 1:03:05Yeah.
- 1:03:06You need the runtime there first and then it'll go much more easily.
- 1:03:10I absolutely think that it is not quite negligence, but it's close that the browser makers don't package other runtimes that are WebAssembly compatible, right?
- 1:03:21Like they should go to Ruby, they should go to Java, they should go to .NET and they should go to Python and say, are you willing to provide us a runtime that does X, Y, and Z that we can integrate in a generic way that we can include in our browser?
- 1:03:36So you don't have to say, oh, well, you can't use these other advanced things because the WebAssembly download is 10 megs.
- 1:03:43Well, if Firefox, Chrome, and Safari all shipped, you know, five of those, the five most common languages as binaries, like you would just have it.
- 1:03:53And it would just be this WebAssembly.
- 1:03:54Why does this not happen?
- 1:03:56So, but that's the real problem to Reactipi is that that's not there, right?
- 1:04:01Yeah.
- 1:04:01All right.
- 1:04:02Quasi says, what is he doing to address the bus factor?
- 1:04:05That is, if you get hit by a bus and then related to that in the audience, Prashat Rana says, well, you include a moderator to the project so it can become a community driven project and there's less burden on you.
- 1:04:19I think those are kind of similar questions from a different perspective.
- 1:04:22Yeah.
- 1:04:23And so the thing is for most of these projects, like most of the work can already be done a lot by the community.
- 1:04:28It's not that the work is, cannot be done.
- 1:04:31I just want to simply enable a bunch of permissions to a lot of people.
- 1:04:36We just go and merge all requests that very quickly because I like to make sure that everything works.
- 1:04:42For example, yesterday, for yesterday's FastAPI release, it had like four approvals, the pull request, but still it had a couple of bugs and a couple of things that needed to be solved.
- 1:04:54And like, I need to make sure that the code quality is still kept and that everything is working correctly.
- 1:05:00So for now, I'm still like making sure that I can give each one of the pull requests.
- 1:05:05But if people went and checked those pull requests and reviewed the code and tested it and like made sure, hey, this is working and I'm using it and it's working in my application or things like that, that will, of course, help a lot.
- 1:05:17Of course, that will help a lot.
- 1:05:19That's great.
- 1:05:19Obviously, it's open source.
- 1:05:21People can fork it.
- 1:05:22They can run with it.
- 1:05:23Like if you actually got hit by a bus, I think FastAPI would keep going.
- 1:05:27There'll just be a figuring out of like, all right, well, where's it going to send her back around before it settles down?
- 1:05:31Yeah, exactly.
- 1:05:31Not that anybody wants to.
- 1:05:33I think these questions are a reflection of how significant the impact you're having on the community is, right?
- 1:05:38Yeah.
- 1:05:39And, you know, like it's, I find the bus factor fun.
- 1:05:42I have been wanting to write a blog post about that for a while because I think the bus factor is something that works a lot for investors or for like founders that are not developers.
- 1:05:55And they are like associating with someone that is the only one that knows the product, but they want to be the owners of half of it.
- 1:06:01And if this person dies, they just lose all their investment.
- 1:06:03But when you're working with one of the things.
- 1:06:05They can keep it going.
- 1:06:06Yeah.
- 1:06:06Yeah.
- 1:06:06Absolutely.
- 1:06:07Like, for example, many of the projects from Nicole is mainly Tom Christie, which is one person.
- 1:06:11The maintainer of Flask, which is huge.
- 1:06:15It's mainly David Lord, and he's just like suffering through all of it and through all the abuse of developers and doing like a lot of the work.
- 1:06:23Probably like, I don't know, see, he has like another contributor or something like that.
- 1:06:26In the case of FastAPI, there's people like Marcelo that is helping a lot.
- 1:06:29And even Samuel Copping is also helping.
- 1:06:31That, you know, helps a lot with keeping the community, maintaining it, and like doing all the work that is needed to be done underneath.
- 1:06:39That doesn't really affect how it's working, you know?
- 1:06:43Like, the fact that the repository is not in another GitHub owner, in a GitHub organization or something like that.
- 1:06:51It's just because it's easier to handle.
- 1:06:53But at the same time, there's a lot of people that are already contributing.
- 1:06:56And that's the work that actually makes maintaining it and sustaining it.
- 1:07:01Exactly.
- 1:07:02That's the stuff that matters.
- 1:07:03Yeah.
- 1:07:03Absolutely.
- 1:07:04Alupia, just by the way, out there also says, I just want to say thanks to...
- 1:07:08You, so, your work is so important and just great.
- 1:07:12So, yeah, definitely a lot of people out there loving it.
- 1:07:14Okay, let's keep going.
- 1:07:16Back to SQL model.
- 1:07:18Roadmap for the future.
- 1:07:19What are the plans?
- 1:07:20So, migrations.
- 1:07:21I want to have a small wrapper to have a command line interface built on top of typer so that you can get into completion in the terminal as well.
- 1:07:29To have migrations based on an embed.
- 1:07:32To documentation for using ASIC with SQL model.
- 1:07:37ASIC is already supported by SQLAlchemy.
- 1:07:39Yeah.
- 1:07:39And that's a new thing, right?
- 1:07:41That is, you've got to create now an ASIC client or an ASIC session rather.
- 1:07:45So, I think it is instead of a regular session in SQLAlchemy.
- 1:07:48But that's one of the 2.0 big changes that Mike just pushed out.
- 1:07:52So, that flows through?
- 1:07:54Yeah.
- 1:07:54Yeah.
- 1:07:55Like, you can already use it.
- 1:07:56In fact, there's people using it in applications, in production applications right now.
- 1:08:00But it's just that I don't have it documented yet.
- 1:08:02SQLAlchemy already supports both the normal, the blocking interface, the regular interface, and the ASIC interface.
- 1:08:10And you can already use it with SQL models.
- 1:08:12But I want to document all that.
- 1:08:14Right.
- 1:08:15So, what you should do is you should just change your dependency injection based on whether you have a DEF method or an ASIC DEF method in FastAPI.
- 1:08:22And either create an ASIC client or ASIC session rather, or regular session, and then boom, off you go, right?
- 1:08:28That is one of the things that I think is so smart about the design of SQLAlchemy, that SQL model in Arids, is that the thing that handles if it's ASIC or not is the engine, not the models themselves.
- 1:08:39So, you can use the same models even if it's ASIC or not.
- 1:08:43I agree.
- 1:08:44Very nice.
- 1:08:44Good question by Lars, but I'm going to keep going because we're short.
- 1:08:47David Smith asked, are there plans to add ASIC?
- 1:08:49Yes.
- 1:08:50I think the question is, are there plans to document ASIC?
- 1:08:52Yeah, exactly.
- 1:08:53At this point, right?
- 1:08:54We kind of touched on this one about whether you should use it for an existing, like, should you be migrating?
- 1:08:59And we touched on that one.
- 1:09:00Rainer, who I think I saw in the audience, yeah, earlier.
- 1:09:02Hey, Brandon.
- 1:09:03Asked, could you go ahead and make NoSQL model?
- 1:09:05This is a chance for me to mention Beanie out there.
- 1:09:09I wanted to kind of ask you if you'd had a chance to look at this.
- 1:09:12So, Roman Wright also was out in the audience.
- 1:09:15I saw them.
- 1:09:15So, Beanie is an ODM, like for MongoDB, but also basically very similar based on Pydantic.
- 1:09:22So, I thought it was a, this immediately came to mind when I thought about SQL model is like, well, here's the MongoDB version.
- 1:09:29Yeah.
- 1:09:30It also, you know, tries to do the same thing.
- 1:09:32Have you thought about a NoSQL story?
- 1:09:34Have you looked at Beanie?
- 1:09:35What are your thoughts here?
- 1:09:36Yeah.
- 1:09:36And like, I really like both, that there are two alternatives for MongoDB with Bynantic.
- 1:09:42One is Beanie.
- 1:09:43The other one is Odmantic.
- 1:09:44I think they are both doing a great job.
- 1:09:46I like this particular thing about Odmantic is that it uses the same style of the interface of SQLAlchemy.
- 1:09:53that the thing that decides if it's async or not is the engine and not the model, which means that it will probably be easier to implement.
- 1:10:02Because both Beanie and Odmantic, both are async.
- 1:10:05Yeah.
- 1:10:06Both having the engine being the one that is async or not will allow implementing a regular or blocking version of it.
- 1:10:15So that you could have MongoDB models that are shared and reused for async code and for blocking code in the same application.
- 1:10:23So you could migrate more slowly and things like that.
- 1:10:26But I think both are doing a great job and like have a very nice interface that is like very close to Python.
- 1:10:32Yeah.
- 1:10:32Just as a sidebar, I do wish it was easier in Python to convert an async call to a synchronous call, knowing that it would block.
- 1:10:41Just go like, okay, here's async method.
- 1:10:44If I could just go dot wait or dot result or something and just make it execute and basically stop the async running from there.
- 1:10:52Then you could just do the query like dot.
- 1:10:54Yeah.
- 1:10:54Give me the answer, right?
- 1:10:55Whereas it's a little more tricky.
- 1:10:57You've got to get it like in the loop and run the loop to completion and stuff like that.
- 1:11:00Yeah.
- 1:11:00But you know, like that's why I just built a async, which is built on top of any IO.
- 1:11:05And the idea is that you have this function asyncify and the function syncify just to do that.
- 1:11:12So you can pass one function that is async and it will be run inside of the main event loop in async way.
- 1:11:20Or you can say, hey, asyncify this thing.
- 1:11:23And it will run the blocking function in a thread pool so that it's not blocking the main event loop, all the stuff.
- 1:11:30But it's actually, the work is actually all done by any IO.
- 1:11:33It's again, just doing the same thing of getting type annotations and other completion and all the stuff on top of the thing that is doing the work.
- 1:11:40Yeah, I definitely came across this not long ago and it looks very exciting.
- 1:11:43And I wanted to talk to you about it.
- 1:11:45But as you can see, we're way over time already for just our main thing.
- 1:11:48So let's go back to it.
- 1:11:49But maybe next time you're on, we could just talk about async stuff all day.
- 1:11:52Mike out there asks, what is the risk of using it in production?
- 1:11:56The risk is the risk that you have for using any software in production.
- 1:12:01Let me maybe rephrase it.
- 1:12:03So what is the readiness for production, I guess, is probably what he was thinking.
- 1:12:08Yeah.
- 1:12:08So the thing is, most of the work is done by Pylandtica and SQLAlchemy.
- 1:12:12And they have been used for years and they are doing an amazing job and they are already used by a lot of tools.
- 1:12:18SQLModal only does like a little bit of extra stuff on top just so that you can need all the type annotations.
- 1:12:24Most of the work is done by those.
- 1:12:26The other thing is that the test coverage is at 97%.
- 1:12:31So you have some certainty that it's working as intended, at least.
- 1:12:35I want to have it at 100% and I want to have tests in continuous integration with several databases.
- 1:12:42Because right now the tests are only run in SQLite.
- 1:12:44But you know that all the SQL stuff is actually done by SQLAlchemy, which is already tested in all the databases.
- 1:12:51So, you know, like there's a trade-off of trying this thing that still has a little bit of extra stuff to do.
- 1:12:57Most of the extra things that I will do on top of SQLModal are actually documentation.
- 1:13:02Not that much whole changes.
- 1:13:04And the ability to flip from one to the other pretty quickly means if you had to say, oh, no, this is not working out.
- 1:13:09We're switching back.
- 1:13:10It's not like, oh, well, you're completely rewriting.
- 1:13:13Yeah.
- 1:13:13It's not that much work.
- 1:13:14You just have to make sure that you're in the versions and you upgrade correctly.
- 1:13:17But otherwise it should be.
- 1:13:19And you will get more certainty about the code correctness because you have all the type.
- 1:13:23So, yeah.
- 1:13:24Yep.
- 1:13:24All right.
- 1:13:25We got one question left.
- 1:13:26You have this ability to take what are often somewhat existing APIs and then improve them in ways that people really connect with.
- 1:13:36Right.
- 1:13:36Like FastAPI didn't start from open TCP socket and let's start from there.
- 1:13:41It started on top of Starlet, right?
- 1:13:43Like you already mentioned, Tom Christie.
- 1:13:45This is on top of two very important libraries that they should go together but didn't.
- 1:13:50So the question Pierre asks is, you know, how did you learn to sort of come up with APIs like you have?
- 1:13:56Like what's your recipe for building these?
- 1:13:57I think the thing is that I have been always trying to solve a problem and I have always trying to improve my developer experience.
- 1:14:06and to improve the way that things work for me.
- 1:14:09And like I have ended up just like trying to understand what is the best way to achieve those things.
- 1:14:14And at some point I ended up learning a little bit about type annotations and I realized that, hey, this can be super powerful.
- 1:14:21I can reuse it for different things.
- 1:14:22And after looking and looking for different frameworks that did what I wanted, I ended up like saying, okay, I just have to build this because it doesn't exist yet.
- 1:14:30But it was just like trying to achieve getting the thing that I want.
- 1:14:35For example, I wouldn't go and build a NoSQL model or MongoDB because there's already Beanie and Nolpatic.
- 1:14:42They are already solving the problem.
- 1:14:44I try to avoid building new things.
- 1:14:46But when there's the case that nothing is really something that I want to have, then I go and try to build it.
- 1:14:54The other thing is I think one of the main features of all these tools is just a good documentation.
- 1:14:59And I guess like the only thing about that is that I write it as I will have liked to learn those things when I was just starting and was struggling to understand what are all these things.
- 1:15:11And I always have in mind like how will that newbie learn these things and understand it.
- 1:15:17I guess that's probably the main thing that I'm trying to do.
- 1:15:20To make it as easy to use as possible.
- 1:15:22Yeah, I feel there's a strong blend of like, let's take the new things that are really useful that maybe not everyone's using and make them very accessible.
- 1:15:29Make them very easy and default and so on.
- 1:15:31Yeah.
- 1:15:31Yeah, that's the learning spirit, I think.
- 1:15:33Yeah, absolutely.
- 1:15:34All right.
- 1:15:35Well, that's all the questions.
- 1:15:37We've been going a little bit long, but I really appreciate the time.
- 1:15:40Let's just real quickly ask you the final two questions.
- 1:15:42I'll let you get out of here.
- 1:15:43All right.
- 1:15:44So if you're going to write some Python code, work on SQL model or something else, what editor do you use these days?
- 1:15:50I think the both main editors, Visual Studio Code and PyCharm are doing an amazing job at supporting all these tools.
- 1:15:57Right now, my main one is Visual Studio Code, but yeah, I will just one of those.
- 1:16:02Okay.
- 1:16:02Very good.
- 1:16:03Very good.
- 1:16:03And then notable PyPI packages.
- 1:16:06I feel like we touched on these a little bit.
- 1:16:07We just mentioned them both, Manthic and Beanie for doing the same SQL model stuff, but for MongoDB.
- 1:16:14Yeah, right on.
- 1:16:14I agree.
- 1:16:15Those are both great.
- 1:16:16All right, Sebastian, it was great to have you back and congratulations on SQL model.
- 1:16:21Maybe next time we'll talk async.
- 1:16:23What do you think?
- 1:16:23Awesome.
- 1:16:24Sounds great.
- 1:16:24Thank you very much, Michael, for inviting me.
- 1:16:26Thank you everyone for staying this long.
- 1:16:28Yeah, you bet.
- 1:16:29See ya.
- 1:16:29See ya.
- 1:16:30Bye.
- 1:16:30This has been another episode of Talk Python To Me.
- 1:16:33Thank you to our sponsors.
- 1:16:35Be sure to check out what they're offering.
- 1:16:37It really helps support the show.
- 1:16:38Datadog gives you visibility into the whole system running your code.
- 1:16:42Visit talkpython.fm/datadog and see what you've been missing.
- 1:16:46Go throw in a free t-shirt with your free trial.
- 1:16:48Tonic.ai creates quality test data that does not contain personally identifiable information.
- 1:16:55Your generated data sets are safe to share with developers, UA, and data scientists.
- 1:17:00Most importantly, they behave like production because they're made from production data.
- 1:17:05Check them out at talkpython.fm/tonic.
- 1:17:09Want to level up your Python?
- 1:17:11We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:17:15Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:17:20And best of all, there's not a subscription in sight.
- 1:17:23Check it out for yourself at training.talkpython.fm.
- 1:17:26Be sure to subscribe to the show.
- 1:17:27Open your favorite podcast app and search for Python.
- 1:17:30We should be right at the top.
- 1:17:32You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:17:42We're live streaming most of our recordings these days.
- 1:17:44If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:17:52This is your host, Michael Kennedy.
- 1:17:54Thanks so much for listening.
- 1:17:55I really appreciate it.
- 1:17:57Now get out there and write some Python code.
- 1:17:58I really appreciate it.
- 1:18:19Thank you.