Credentials, shown once
Your app receives its database credentials through environment variables. For external clients, creation and rotation return a password to store securely.
- host
- db.example.com
- port
- 5432
- username
- orders_app
- password
- shown once
Create Postgres, MySQL, or SQLite databases from the SDK. Connection details are automatically available in your app as environment variables, ready for the driver you already use.
One engine is picked out of Postgres, MySQL, and SQLite, and a database of that kind is created. StackMachine exposes its connection details as environment variables to the app. The app queries that database, and rows come back.
Connection details, automatically available in your app.
DB_NAMEDB_USERNAMEDB_PASSWORDDB_HOSTDB_PORTAn illustration, with example data.
Powering products and agents at
DB_NAME, DB_USERNAME, DB_PASSWORD, DB_HOST, and DB_PORT from your app's environment. Use the client library your app already has.Create the database against an app and connect using its automatically configured environment variables. Rotate the credentials later from the same client.
$ npm install stackmachineimport StackMachine from "stackmachine";
const client = new StackMachine(process.env.STACKMACHINE_API_KEY);
const { database, password } = await client.apps.databases.create({
app: "da_XYZ",
dbEngine: "POSTGRES", // or "MYSQL", "SQLITE"
name: "orders",
});
// The app receives DB_NAME, DB_USERNAME, DB_PASSWORD, DB_HOST, and DB_PORT.
// Connect with your Postgres driver using the app's environment.
// Store password securely if an external client needs it.
console.log(database.host, database.port, database.username);
const rotated = await client.apps.databases.rotateCredentials(database.id);Keep records, user data, and queues next to the app that uses them.
Your app receives its database credentials through environment variables. For external clients, creation and rotation return a password to store securely.
Databases are created against an app and listed with it, so every project has its own state and its own engine.
More in the documentation.
One API key for hosting, storage, databases, email, and cron.