External SQL Database
While actors can serve as a complete database solution, they can also complement your existing databases. For example, you might use actors to handle frequently-changing data that needs real-time access, while keeping less frequently accessed data in your traditional database.
Actors can be used with common SQL databases, such as PostgreSQL and MySQL.
Libraries
To facilitate interaction with SQL databases, you can use either ORM libraries or raw SQL drivers. Each has its own use cases and benefits:
-
ORM Libraries: Type-safe and easy way to interact with your database
-
Raw SQL Drivers: Direct access to the database for more flexibility
Hosting Providers
There are several options for places to host your SQL database:
Example
Here’s a basic example of how you might set up a connection to a PostgreSQL database using the pg
library:
With Drizzle ORM
Here’s an example using Drizzle ORM for more type-safe database operations: