From the course: Complete Guide to Open Source Security

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Scripting with Valkey

Scripting with Valkey

- [Instructor] We've already used the command line tool to access the Valkey system. So let's now see how we access it via Python. We firstly need to install the Valkey Library with pip install valkey. Okay, now let's start at Python and run some interactive commands. And we'll first import the library and we'll set up a handle to it with vk - valkey.valkey. And we'll say host='local host'. We could be running Valkey on a remote server. We're not at the moment. port=6379 which is the default port and db=0. And we're using db=0 to use the default database. But we could have multiple databases each with their own index. Let's set a key. vk.set myname and we'll set that to Malcolm. and now let's get it back. So we'll get what's in the key store under the key, myname. Okay, and we've got Malcolm back from the key myname. And of course, if we want to print it, we would print vk.get myname and we'd decode it to a string. So we can copy this value to another key. vk.copy('myname'…

Contents