1# -*- coding: utf-8 -*- #
2# Copyright 2017 Google LLC. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#    http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15"""Defines tool-wide constants."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import unicode_literals
20
21# Defaults for instance creation.
22DEFAULT_MACHINE_TYPE = 'db-n1-standard-1'
23
24# Determining what executables, flags, and defaults to use for sql connect.
25DB_EXE = {'MYSQL': 'mysql', 'POSTGRES': 'psql', 'SQLSERVER': 'mssql-cli'}
26
27EXE_FLAGS = {
28    'mysql': {
29        'user': '-u',
30        'password': '-p',
31        'hostname': '-h',
32        'port': '-P'
33    },
34    'psql': {
35        'user': '-U',
36        'password': '-W',
37        'hostname': '-h',
38        'port': '-p',
39        'database': '-d'
40    },
41    'mssql-cli': {
42        'user': '-U',
43        'hostname': '-S',
44        'database': '-d'
45    }
46}
47
48DEFAULT_SQL_USER = {
49    'mysql': 'root',
50    'psql': 'postgres',
51    'mssql-cli': 'sqlserver'
52}
53
54# Size conversions.
55BYTES_TO_GB = 1 << 30
56
57# Cloud SQL Proxy constants.
58
59# Generally unassigned port number for the proxy to bind to.
60DEFAULT_PROXY_PORT_NUMBER = 9470
61
62PROXY_ADDRESS_IN_USE_ERROR = 'bind: address already in use'
63
64PROXY_READY_FOR_CONNECTIONS_MSG = 'Ready for new connections'
65