What is @googleapis/sqladmin?
@googleapis/sqladmin is an npm package that provides access to the Google Cloud SQL Admin API. This API allows you to manage Cloud SQL instances, including creating, configuring, and deleting instances, as well as managing databases, users, and other resources within those instances.
What are @googleapis/sqladmin's main functionalities?
Create a Cloud SQL Instance
This feature allows you to create a new Cloud SQL instance with specified settings such as tier, disk size, disk type, and region.
const {google} = require('@googleapis/sqladmin');
const sqladmin = google.sqladmin('v1beta4');
async function createInstance(auth) {
const request = {
project: 'your-project-id',
resource: {
name: 'instance-name',
settings: {
tier: 'db-f1-micro',
dataDiskSizeGb: '10',
dataDiskType: 'PD_SSD',
region: 'us-central1'
}
},
auth: auth
};
try {
const response = await sqladmin.instances.insert(request);
console.log(response.data);
} catch (err) {
console.error(err);
}
}
List Cloud SQL Instances
This feature allows you to list all Cloud SQL instances within a specified project.
const {google} = require('@googleapis/sqladmin');
const sqladmin = google.sqladmin('v1beta4');
async function listInstances(auth) {
const request = {
project: 'your-project-id',
auth: auth
};
try {
const response = await sqladmin.instances.list(request);
console.log(response.data.items);
} catch (err) {
console.error(err);
}
}
Delete a Cloud SQL Instance
This feature allows you to delete a specified Cloud SQL instance.
const {google} = require('@googleapis/sqladmin');
const sqladmin = google.sqladmin('v1beta4');
async function deleteInstance(auth) {
const request = {
project: 'your-project-id',
instance: 'instance-name',
auth: auth
};
try {
const response = await sqladmin.instances.delete(request);
console.log(response.data);
} catch (err) {
console.error(err);
}
}
Create a Database in a Cloud SQL Instance
This feature allows you to create a new database within a specified Cloud SQL instance.
const {google} = require('@googleapis/sqladmin');
const sqladmin = google.sqladmin('v1beta4');
async function createDatabase(auth) {
const request = {
project: 'your-project-id',
instance: 'instance-name',
resource: {
name: 'database-name'
},
auth: auth
};
try {
const response = await sqladmin.databases.insert(request);
console.log(response.data);
} catch (err) {
console.error(err);
}
}
List Databases in a Cloud SQL Instance
This feature allows you to list all databases within a specified Cloud SQL instance.
const {google} = require('@googleapis/sqladmin');
const sqladmin = google.sqladmin('v1beta4');
async function listDatabases(auth) {
const request = {
project: 'your-project-id',
instance: 'instance-name',
auth: auth
};
try {
const response = await sqladmin.databases.list(request);
console.log(response.data.items);
} catch (err) {
console.error(err);
}
}
Other packages similar to @googleapis/sqladmin
aws-sdk
The aws-sdk package provides access to AWS services, including Amazon RDS, which is similar to Google Cloud SQL. It allows you to manage RDS instances, databases, and users. Compared to @googleapis/sqladmin, aws-sdk offers a broader range of services beyond just database management.
azure-arm-sql
The azure-arm-sql package provides access to Azure SQL Database management. It allows you to create, configure, and manage SQL databases and servers on Microsoft Azure. This package is similar to @googleapis/sqladmin but is specific to the Azure cloud platform.
node-postgres
The node-postgres package is a collection of node.js modules for interfacing with PostgreSQL databases. While it does not provide cloud-specific management features like @googleapis/sqladmin, it is useful for managing PostgreSQL databases directly.
sqladmin
API for Cloud SQL database instance management
Installation
$ npm install @googleapis/sqladmin
Usage
All documentation and usage information can be found on GitHub.
Information on classes can be found in Googleapis Documentation.
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
Contributing
We love contributions! Before submitting a Pull Request, it's always good to start with a new issue first. To learn more, see CONTRIBUTING.
Questions/problems?
Crafted with ❤️ by the Google Node.js team