azure.servicemanagement.sqldatabasemanagementservice module

class azure.servicemanagement.sqldatabasemanagementservice.SqlDatabaseManagementService(subscription_id=None, cert_file=None, host='management.core.windows.net', request_session=None, timeout=65)[source]

Bases: azure.servicemanagement.servicemanagementclient._ServiceManagementClient

Note that this class is a preliminary work on SQL Database management. Since it lack a lot a features, final version can be slightly different from the current one.

Initializes the sql database management service.

subscription_id:
Subscription to manage.
cert_file:
Path to .pem certificate file (httplib), or location of the certificate in your Personal certificate store (winhttp) in the CURRENT_USERmyCertificateName format. If a request_session is specified, then this is unused.
host:
Live ServiceClient URL. Defaults to Azure public cloud.
request_session:
Session object to use for http requests. If this is specified, it replaces the default use of httplib or winhttp. Also, the cert_file parameter is unused when a session is passed in. The session object handles authentication, and as such can support multiple types of authentication: .pem certificate, oauth. For example, you can pass in a Session instance from the requests library. To use .pem certificate authentication with requests library, set the path to the .pem file on the session.cert attribute.
timeout:
Optional. Timeout for the http request, in seconds.
create_database(server_name, name, service_objective_id, edition=None, collation_name=None, max_size_bytes=None)[source]

Creates a new Azure SQL Database.

server_name:
Name of the server to contain the new database.
name:
Required. The name for the new database. See Naming Requirements in Azure SQL Database General Guidelines and Limitations and Database Identifiers for more information.
service_objective_id:
Required. The GUID corresponding to the performance level for Edition. See List Service Level Objectives for current values.
edition:
Optional. The Service Tier (Edition) for the new database. If omitted, the default is Web. Valid values are Web, Business, Basic, Standard, and Premium. See Azure SQL Database Service Tiers (Editions) and Web and Business Edition Sunset FAQ for more information.
collation_name:
Optional. The database collation. This can be any collation supported by SQL. If omitted, the default collation is used. See SQL Server Collation Support in Azure SQL Database General Guidelines and Limitations for more information.
max_size_bytes:
Optional. Sets the maximum size, in bytes, for the database. This value must be within the range of allowed values for Edition. If omitted, the default value for the edition is used. See Azure SQL Database Service Tiers (Editions) for current maximum databases sizes. Convert MB or GB values to bytes. 1 MB = 1048576 bytes. 1 GB = 1073741824 bytes.
create_firewall_rule(server_name, name, start_ip_address, end_ip_address)[source]

Creates an Azure SQL Database server firewall rule.

server_name:
Name of the server to set the firewall rule on.
name:
The name of the new firewall rule.
start_ip_address:
The lowest IP address in the range of the server-level firewall setting. IP addresses equal to or greater than this can attempt to connect to the server. The lowest possible IP address is 0.0.0.0.
end_ip_address:
The highest IP address in the range of the server-level firewall setting. IP addresses equal to or less than this can attempt to connect to the server. The highest possible IP address is 255.255.255.255.
create_server(admin_login, admin_password, location)[source]

Create a new Azure SQL Database server.

admin_login:
The administrator login name for the new server.
admin_password:
The administrator login password for the new server.
location:
The region to deploy the new server.
delete_database(server_name, name)[source]

Deletes an Azure SQL Database.

server_name:
Name of the server where the database is located.
name:
Name of the database to delete.
delete_firewall_rule(server_name, name)[source]

Deletes an Azure SQL Database server firewall rule.

server_name:
Name of the server with the firewall rule you want to delete.
name:
Name of the firewall rule you want to delete.
delete_server(server_name)[source]

Deletes an Azure SQL Database server (including all its databases).

server_name:
Name of the server you want to delete.
get_server_event_logs(server_name, start_date, interval_size_in_minutes, event_types='')[source]

Gets the event logs for an Azure SQL Database Server.

server_name:
Name of the server to retrieve the event logs from.
start_date:
The starting date and time of the events to retrieve in UTC format, for example ‘2011-09-28 16:05:00’.
interval_size_in_minutes:
Size of the event logs to retrieve (in minutes). Valid values are: 5, 60, or 1440.
event_types:

The event type of the log entries you want to retrieve. Valid values are:

  • connection_successful
  • connection_failed
  • connection_terminated
  • deadlock
  • throttling
  • throttling_long_transaction

To return all event types pass in an empty string.

list_databases(name)[source]

List the SQL databases defined on the specified server name

list_firewall_rules(server_name)[source]

Retrieves the set of firewall rules for an Azure SQL Database Server.

server_name:
Name of the server.
list_quotas(server_name)[source]

Gets quotas for an Azure SQL Database Server.

server_name:
Name of the server.
list_servers()[source]

List the SQL servers defined on the account.

list_service_level_objectives(server_name)[source]

Gets the service level objectives for an Azure SQL Database server.

server_name:
Name of the server.
set_server_admin_password(server_name, admin_password)[source]

Reset the administrator password for a server.

server_name:
Name of the server to change the password.
admin_password:
The new administrator password for the server.
update_database(server_name, name, new_database_name=None, service_objective_id=None, edition=None, max_size_bytes=None)[source]

Updates existing database details.

server_name:
Name of the server to contain the new database.
name:
Required. The name for the new database. See Naming Requirements in Azure SQL Database General Guidelines and Limitations and Database Identifiers for more information.
new_database_name:
Optional. The new name for the new database.
service_objective_id:
Optional. The new service level to apply to the database. For more information about service levels, see Azure SQL Database Service Tiers and Performance Levels. Use List Service Level Objectives to get the correct ID for the desired service objective.
edition:
Optional. The new edition for the new database.
max_size_bytes:
Optional. The new size of the database in bytes. For information on available sizes for each edition, see Azure SQL Database Service Tiers (Editions).
update_firewall_rule(server_name, name, start_ip_address, end_ip_address)[source]

Update a firewall rule for an Azure SQL Database server.

server_name:
Name of the server to set the firewall rule on.
name:
The name of the firewall rule to update.
start_ip_address:
The lowest IP address in the range of the server-level firewall setting. IP addresses equal to or greater than this can attempt to connect to the server. The lowest possible IP address is 0.0.0.0.
end_ip_address:
The highest IP address in the range of the server-level firewall setting. IP addresses equal to or less than this can attempt to connect to the server. The highest possible IP address is 255.255.255.255.