YouTubevideo· Jan 11, 2025· 17:27
I've always been a fan of turo mostly just because of how easy it is to get uh a remote SQL database up and running I've been a fan of turo Mostly because if I'm building something and hosting it on lville Vapor then I want something that isn't RDS I want something extremely simple that I could just connect to and if you're in a serverless setting like AWS you can't really have a persisted sqlite database but you can
with turo but I just saw this announcement that turo has now dropped a new driver specifically for Lille PHP and uh why don't we give it a look and see what see what's up I've talked about turo a couple of times I actually built a full uh project using turo with a multi-tenant database in the sense that okay every single time a new user is
created in your application you're generating a new turo database and it it it's easy because because they have an API where you can just generate a new database and figuring out okay where do those environment variables live and now I'm connecting to it but I think this new driver should make that a lot easier because one of the things that It's Tricky with the lib SQL um I think it have a sanctioned community driver in the sense that it was officially
supported or maybe sanctioned or at least encouraged by turo team but now I think they have their own one so let's take a look announcing larel support imped HP PDO interface Lille continues to grow rapidly in popularity it's a defective framework for PHP and many people have been Keen to use it with terso it's technically already been available to use with turo through Community drivers were're excited to
launch official laral support with lib SQL larl our new open- source SDK this is the bread and butter because turo I could be getting this completely wrong but turo forked SQL to create lib SQL and because there's some additional benefits on top of SQL light it needed specific extensions within PHP which
meant it was very it was tricky to use unless you were uh downloading specific extensions and depending on your where you're hosting your lville application that package might be tricky to use I'm curious of how resolved this maybe or at least used something different I'm imagining okay what this means for l developers we have dropin SQL like compatibility compatible code migrations will work with TSO without modification
that's always nice uh I don't I'm curious then because I know so for example like laravel a database drivers if we take a look at the specific database we don't necessarily have Lal does not have a specific sqlite it has a sqlite driver but not lib SQL which is a different database so I'm imagining this is probably a a package from turo to of get that up and running so we have SIMPLE
configuration okay database URL and Native larel connection so integrates with the connection Factory and database manager okay looks all great turo lib SQL LEL update EnV and is that it that's pretty crazy why don't I run through this because I'm curious of like how this is working
especially when a lot of the things you lose out on lip if you wanted to in the past when I was using turo most of the time I just needed to connect to something quick to have a database storage without having to set up spin up a whole new RDS database that was most of what I was losing for especially for my smaller projects but I really couldn't tap into the embedded replicas or vector stuff because it wasn't
supported or it was just tricky to get it running in my particular setup so let's make this happen why don't I jump into my code editor and spin up a new starter kit using my vision starter kit and then we'll see what's up maybe we'll do GH repo clone and then we'll say Josh Siri fion and why don't we call this a turo check turo check I'm just going to run my install script which basically just gets everything set up and running
for me within this particular application we'll say yes and then we'll run PHP Artisan solo which should get us up and running and we are good to go so this is my fision starter kit and now let's connect terso I apologize back and forth between switching between light mode and dark mode with uh my actual page and then the turo documentation here's your warning avert your eyes so we're going to go ahead and composer
require turo larl we'll go ahead and do that okay so spany larel package tools we've got lib SQL larvo and lib SQL by turo and everything looks like everything's good to go there we need to update our EnV with credentials so we have DB connection a turo database URL and a turo off the token I'm going to hide my screen real quick and just push
that in okay I've got my environment variables all set up I'm going to add this lib SQL driver to my database.php and now we should be good to go so we emit the URL and password to use lip SQL locally but we're not going to use Al we're going to be connected kind of just pushing everything up even though our uh app is set up locally it is nice to know you can still use lipsq locally though um I don't necessarily know what that
means in the sense that maybe I don't know you can still use the embedded replicas and Vector embedding all right let's go ahead and just follow the instructions that it gives I'm curious to see what this enables for us so we're going to make a model with a movie and make a migration for it as well let's do that so PHP artisan make model movie and we're going to make a migration for it perfect let's go ahead and put this
files and have a cast a vector cast which looks like it uses little SQL larel Vector cast is very interesting so in the movie so we have this Vector cast that we're going to bring in from lip SQL Lille Vector cast now we set up the migration to create the movies table which is a plot embedding which is a vector okay a five-dimensional vector very
interesting I don't necessarily know if I've ever used a vector in a migration before I do use PG vector and I can't remember off without my head if I use a vector column I imagine I probably do but I thought it was something else it's probably vector and now we're going to create a vector index so I'm assuming what the vector index is doing is this
going to give us the ability to search on that Vector column so we're going to create a add Vector index to movies table and I'm assuming this Vector index cannot be done it's not like I can in here say that I want to add a vector index an index or even a vector index it probably has to be separate for a particular reason I don't necessarily know it'd be nice if I could maybe see it right here because that's something
that is really interesting to me to know okay is this the best way to do it every single time that's what we're going to do let's go ahead and create that uh Vector index migration there and we want to add the to the table add that Vector index plot embedding okay and I don't did I call it a plot embedding okay we did so it's
basically just saying I want that I want to add a vector index to the plot embedding column and have this mood plot embedding idx now we run our migrations okay and it's taking a little bit slower because we are connecting locally I'm not locally but we are connecting to that turo database if I was to pull up torso we should see now some data and if I was to edit this I believe they have yeah
drizzle Studio outer base embedded outer base I was to open up in drizzle studio for example I should see information now so yeah we have our movies I also have my migrations as well so the you know s s and pan analytics for example where let's say if I was to I believe in the playground I believe I
have a yeah data pan playground button so if I was to set up or log into my account strict enabled I don't know why I'm getting that error let's go ahead so I didn't actually know if F API is but it looks like it is a specific PHP inii setting because when I changed it in my herd
config to ffi doable equals true it looks like everything's working now so let's go ahead and create a new account and we should be good to go so Josh yeah that created a new account in the turo database because if I was to open this back up and look at the users table for example we should see yes there is my
name and email and I want to show that if I check on playground and click on this High everyone button we should now see that information in the pan analytics and sure enough if we open up the terminal and I run PHP Artisan pan we'll grab that from the database as well and it looks like database analytics repository okay looks like the pan analytics that I I've been using by
n Maduro looks like um maybe something is not set up properly for something other than the typical database connection strings but that's okay the cool part is that everything seems to be working now well now let's go ahead and see that whole movie setup where we can then Vector search based off of it okay it says for example you can create a new movie and then you're able to find similar movies like this and I wonder if
we can find a way to like create a whole bunch of different movies but this is basically on a super basic level it looks like there's specific plot embeddings and then we can query based off of other embeddings and so you would use this for something like open apis embedding search where you're basically saying okay hey here's all this information about a movie store this as an embedding and then you would put that
in that plot embedding column but then we can just search based off of this query it looks like so movie query nearest the movie plot embedding idx with this specific query Vector so yeah if I was to create a new movie and then the playground let's go ahead and just say this is a public function add movie and we'll just say movie is this and and then if we
were to wire this up say like wire click equals add movie then in order to find similar movies you would do something like this and what we could do is just say I don't know create a new function call public function find movies and we'll just say and we just DD similar movies so what should happen is
if we were to create a new button we just say flux button wi click equals find movies now in our application what we should see is two buttons being able to say okay this High everyone button it adds a new movie oh call to undefine cast interesting so plot embedding maybe we didn't save that model let's go ahead
and say the movie model did we not save this let's go ahead and refresh okay there we go probably didn't save that mod since we created it and then find similar movies we should no such column to do. rid interesting I don't know where the toos is coming from but we're adding we're adding something to the database so if I was to recheck like this movies
for example yeah we have two Matrix added but no plot embeddings that's really interesting I guess it's an aray buff or maybe I just can't see so I'm guessing I'm doing something wrong or maybe just something's not set up properly within my set so I'm cutting in real quick because while editing I did see that the turo lip SQL larl driver and GitHub did have a issue a poll request that was
actually merged about 20 hours ago where it's there was an issue with specifically todd. row. that is still that looks like it wasn't fully merged or fully released into the new release so if I also take a look at the package itself and the actual releases there's two that are tagged 0.1.1 but that does not include that specific PR so that is
probably where the issue is coming from I would imagine if you just pulled the lip SQL lelt from the actual main branch the latest Dev Branch then it should be good to go uh back to the video but the cool part is that this is out of the box for you within like if I was doing PG SQL within laravel for example I can't remember exactly how I was doing it but I don't believe you
have that easy search of vector so let's see if I can find something of the pgs of vector okay yeah I think I did I do remember having to do a DB statement instead of having to do like that index so that becomes a lot easier if I'm doing a specific Vector index within a migrations that becomes easier okay yeah we're casting to a vector looks like that was the PG Vector package that that
was recommended yeah I think the the difference in what you're able to do within within like the nearest for example is really interesting because whatever however this is being stored is a little bit different than what you would store in PG Vector which it looks like usually would have to do like an order by raw like taking I want this particular embedding based off of if it's closest
to this embedding which is a a you kind of push it into vectors I'm curious of like how you would get this query Vector which again is probably through something like open AI I wonder if this would be a good example of like what Prism by TJ is doing TJ Miller I wonder if he's doing anything with vectors let's see yeah embeddings here we go yeah so you can generate embeddings with
just a few lines of code with in prism which is great so you can have you're you're saying okay I want to generate from the embeddings I want to say that this is the text and in this case you would put like your movie description or movie name or maybe just of it I would imagine you can do more than just text I've done that before or it just could be like a huge line of text and now you
have your embeddings and this is what I would believe you would then put into your plot embedding where you could say okay you know I would do something like this where to add movie I would get the prism embeddings and then place this into the embeddings and it depends like what it's good back but this is a good example of how you can use multiple
things like Tso's vector embeddings and not have to worry about setting you know a PG extension with PG vector and use something like prism which I'm hoping to do a little bit more of a deep dive to say okay I'm generating these embeddings and now I can just work with them because I have the information I need from something like open AI to have this group of information boiled down into
these this this Vector overall super excited for what the team is doing at turo and I think this just adds a little bit more options for what you're doing within Lille if you wanted to do Vector embeddings which to me is probably one of the bigger selling points of something like a lib SQL and as as well as embedded replicas like stuff like that is really interesting because you have what feels like a very fast
database because it's being embedded in your like on your application as well as being remote connection um but then also just being able to like those vectors without having to do something like pgsql which is a separate extension so even if you have access um to a the your postcard database you still have to make sure that you add that extension then you do all this extra stuff it still is
great but having this is another great option as well so I love what turo theme is doing allows you to keep building keep creating