# page sections to the SQL Editor sidebar and save a reference to itself in the SQL Editor
# object's customData dictionary.
# No other initialization is done at this time (ie, no DB connections or GUI is setup).
#
# = When an admin item is selected in the sidebar
#
# - Setup the main admin GUI view and dock it to the SQL Editor.
# - If the entry requires a ssh connection, it will try to open that connection and the
#   admin specific DB connection, unless it's already connected.
#   If not, it will open the DB connection only.
# - Then it will setup the GUI for the requested admin page and dock it/switch to it.
#


# define this Python module as a GRT module
ModuleInfo = DefineModule(name= "WbAdmin", author= "Oracle Corp.", version="2.0")

class DBError(Exception):
    pass

#-------------------------------------------------------------------------------
wba_page_modules = []

#===============================================================================
#
#===============================================================================
class AdministratorContext:
    """
    An instance of the WBA, associated to a SQL Editor.
    Thi is created when a GRNSQLEditorOpened notification is received.
import random
import os.path

from wb import DefineModule
from workbench import db_driver
from workbench.utils import find_object_with_name
from workbench.exceptions import NotConnectedError

from db_generic_re_grt import GenericReverseEngineering

import SQLEXT as constant

import grt

ModuleInfo = DefineModule(name="DbMsAccessRE",
                          author="Oracle Corp.",
                          version="1.0")


def normalize_schema_name(path):
    """Turns an Access DB file path into something resembling a schema name"""
    return os.path.splitext(os.path.basename(path))[0]


class MsAccessReverseEngineering(GenericReverseEngineering):
    _connections = {}

    @classmethod
    def check_interruption(cls):
        if grt.query_status():
            raise grt.UserInterrupt()
Example #3
0
schemaCreateTemplate = '''
           Schema::table('{tableName}', function (Blueprint $table) {{
'''

indexKeyTemplate = '''
            $table->{indexType}([{indexColumns}], '{indexName}');
'''

migrationEndingTemplate = '''        Schema::dropIfExists($this->tableName);
    }}
}}
'''

ModuleInfo = DefineModule(name='GenerateLaravel5Migration',
                          author='Brandon Eckenrode',
                          version='0.2')


@ModuleInfo.plugin('wb.util.generate_laravel5_migration',
                   caption='Export Laravel 5 Migration',
                   input=[wbinputs.currentCatalog()],
                   groups=['Catalog/Utilities', 'Menu/Catalog'],
                   pluginMenu='Catalog')
@ModuleInfo.export(grt.INT, grt.classes.db_Catalog)
def generate_laravel5_migration(catalog):
    def create_tree(table_schema):
        tree = {}
        for tbl in sorted(table_schema.tables, key=lambda table: table.name):
            table_references = []
Example #4
0
import cStringIO
import glob
import os

import grt
import mforms
import datetime
import time

from grt.modules import Workbench
from wb import DefineModule, wbinputs
from workbench.ui import WizardForm, WizardPage
from mforms import newButton, newCodeEditor, FileChooser

ModuleInfo = DefineModule(name='GenerateKnexMigration',
                          author='Author',
                          version='1.0.0')
migrations = {}
migration_tables = []

typesDict = {
    'BIG_INCREMENTS': 'increments',
    'MEDIUM_INCREMENTS': 'mediumIncrements',
    'INCREMENTS': 'increments',
    'TINYINT': 'integer',
    'uTINYINT': 'integer',
    'SMALLINT': 'integer',
    'uSMALLINT': 'unsignedSmallInteger',
    'MEDIUMINT': 'mediumInteger',
    'uMEDIUMINT': 'unsignedMediumInteger',
    'INT': 'integer',
# separately licensed software that they have included with MySQL.
# This program is distributed in the hope that it will be useful,  but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
# the GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

from wb import DefineModule
import grt
import mforms
import db_copy_main

ModuleInfo = DefineModule(name= "SchemaTransferWizard", author= "Oracle Corp.", version="1.0")

tab_reference = None

#-------------------------------------------------------------------------------
def handle_view_close(view):
    global tab_reference
    tab_reference = None
    view.cleanup()
    return True

#-------------------------------------------------------------------------------
@ModuleInfo.plugin("wb.db.copy.open", type="standalone", caption= "Schema Transfer Wizard",  pluginMenu= "Schema Transfer Wizard")
@ModuleInfo.export(grt.INT)
def openDBCopy():
    global tab_reference
Example #6
0
# import the wb module
from wb import DefineModule, wbinputs
# import the grt module
import grt
# import the mforms module for GUI stuff
import mforms

from sql_reformatter import node_value, node_symbol, node_children, find_child_node, find_child_nodes, trim_ast, ASTHelper, dump_tree, flatten_node

# define this Python module as a GRT module
ModuleInfo = DefineModule(name="CodeUtils",
                          author="Oracle Corp.",
                          version="1.0")


@ModuleInfo.plugin("wb.sqlide.copyAsPHPConnect",
                   caption="Copy as PHP Code (Connect to Server)",
                   input=[wbinputs.currentSQLEditor()],
                   pluginMenu="SQL/Utilities")
@ModuleInfo.export(grt.INT, grt.classes.db_query_Editor)
def copyAsPHPConnect(editor):
    """Copies PHP code to connect to the active MySQL connection to the clipboard.
    """
    if editor.connection:
        conn = editor.connection

        if conn.driver.name == "MysqlNativeSocket":
            params = {
                "host": "p:localhost",
                "port": 3306,
                "user": conn.parameterValues["userName"],
Example #7
0
import cStringIO
import glob
import os

import grt
import mforms
import datetime
import time

from grt.modules import Workbench
from wb import DefineModule, wbinputs
from workbench.ui import WizardForm, WizardPage
from mforms import newButton, newCodeEditor, FileChooser

ModuleInfo = DefineModule(name='GenerateAdonisJSMigration',
                          author='Brandon Eckenrode & Mahendaran',
                          version='1.0.0')
migrations = {}
migration_tables = []

typesDict = {
    'BIG_INCREMENTS': 'increments',
    'MEDIUM_INCREMENTS': 'mediumIncrements',
    'INCREMENTS': 'increments',
    'TINYINT': 'integer',
    'uTINYINT': 'integer',
    'SMALLINT': 'integer',
    'uSMALLINT': 'unsignedSmallInteger',
    'MEDIUMINT': 'mediumInteger',
    'uMEDIUMINT': 'unsignedMediumInteger',
    'INT': 'integer',
Example #8
0
# conversor de MySQL a SQLite
# Written in MySQL Workbench 8.0.22

import re
import StringIO

import grt
import mforms

from grt.modules import Workbench
from wb import DefineModule, wbinputs
from workbench.ui import WizardForm, WizardPage
from mforms import newButton, newCodeEditor, FileChooser

ModuleInfo = DefineModule(name='ToSQLite',
                          author='Jose Uzcategui',
                          version='1.0')


@ModuleInfo.plugin('wb.util.ToSQLite',
                   caption='To SQLite',
                   input=[wbinputs.currentCatalog()],
                   groups=['Catalog/Utilities', 'Menu/Catalog'])
@ModuleInfo.export(grt.INT, grt.classes.db_Catalog)
def exportSQLite(cat):
    #------------------------------------------------------------------------
    # format header author, dates, version, etc
    def info_format(header, body):
        verbody = lineFormat(body)
        retString = ''
        if verbody == '':
#
# Drupal query formatter for MySQL Workbench
#
# Created by Tom Kaminski ([email protected]) 2013-10-03

from wb import DefineModule, wbinputs
import grt
import mforms
import re
from sql_reformatter import formatter_for_statement_ast, ASTHelper
from grt import log_info, log_error, log_warning, log_debug, log_debug2, log_debug3

# Define as a GRT module
ModuleInfo = DefineModule(name="DrupalUtils",
                          author="Tom Kaminski ([email protected])",
                          version="1.0")

##########################################


@ModuleInfo.plugin("wb.sqlide.stripTableBraces",
                   caption="Strip curly braces from table names",
                   input=[wbinputs.currentQueryBuffer()],
                   pluginMenu="SQL/Utilities")
@ModuleInfo.export(grt.INT, grt.classes.db_query_QueryBuffer)
def stripTableBraces(buffer):
    selectionOnly = True
    text = buffer.selectedText

    if not text:
        selectionOnly = False
Example #10
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

from db_sql92_re_grt import Sql92ReverseEngineering

from wb import DefineModule
from workbench.utils import find_object_with_name

import grt

ModuleInfo = DefineModule(name="DbPostgresqlRE",
                          author="Oracle Corp.",
                          version="1.0")


class PostgresqlReverseEngineering(Sql92ReverseEngineering):
    @classmethod
    def getTargetDBMSName(cls):
        return 'Postgresql'

    @classmethod
    def serverVersion(cls, connection):
        return cls._connections[connection.__id__]["version"]

    @classmethod
    def connect(cls, connection, password):
        r = super(PostgresqlReverseEngineering,
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import sqlite3
import os.path

from db_generic_re_grt import GenericReverseEngineering

from wb import DefineModule
from workbench.utils import server_version_str2tuple
from workbench.exceptions import NotConnectedError

import grt

ModuleInfo = DefineModule(name="DbSQLiteRE",
                          author="Oracle Corp.",
                          version="1.0")


class SQLiteReverseEngineering(GenericReverseEngineering):
    @classmethod
    def getTargetDBMSName(cls):
        return 'SQLite'

    @classmethod
    def serverVersion(cls, connection):
        return cls._connections[connection.__id__]["version"]

    #########  Connection related functions #########
    @classmethod
    def connect(cls, connection, password):
Example #12
0
from text_output import TextOutputTab
from run_script import RunScriptForm
from sqlide_catalogman_ext import show_schema_manager
from sqlide_tableman_ext import show_table_inspector

from sqlide_resultset_ext import handleResultsetContextMenu
import sqlide_catalogman_ext
import sqlide_tableman_ext
import sqlide_schematree_ext
import sqlide_import_spatial
import sqlide_power_import_wizard
import sqlide_power_export_wizard

# define this Python module as a GRT module
ModuleInfo = DefineModule(name="PHPArrayFromResultSet",
                          author="z3niths",
                          version="1.0")


@ModuleInfo.plugin('wbblog.executePHPArrayFromResultSet',
                   caption='Show PHP Array From Resultsets',
                   input=[wbinputs.currentQueryEditor()],
                   pluginMenu="SQL/Utilities")
@ModuleInfo.export(grt.INT, grt.classes.db_query_QueryEditor)
def executePHPArrayFromResultSet(editor):
    statement = editor.currentStatement
    if statement:
        rsets = editor.owner.executeScript(statement)
        output = ['> %s\n' % statement]
        for idx, rset in enumerate(rsets):
            if len(rsets) > 1:
Example #13
0
import sys
import subprocess
import os
import threading
import zipfile
import tempfile

# import the wb module
from wb import DefineModule, wbinputs
# import the grt module
import grt
import mforms

# define this Python module as a GRT module
ModuleInfo = DefineModule(name="PyWbUtils",
                          author="Sun Microsystems Inc.",
                          version="1.0")

# wb_model_utils contains a few more plugins that will get registered when imported
import wb_model_utils  # noqa


def get_linux_terminal_program():
    paths = os.getenv("PATH").split(":")
    if not paths:
        paths = ['/usr/bin', '/usr/local/bin', '/bin']

    for term in ["gnome-terminal", "konsole", "xterm", "rxvt"]:
        for d in paths:
            full_path = os.path.join(d, term)
            if os.path.exists(full_path):
Example #14
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
# the GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import re

from wb import DefineModule

import grt

from db_generic_migration_grt import GenericMigration

ModuleInfo = DefineModule(name= "DbSQLAnywhereMigration", author= "Oracle Corp.", version="1.0")


class SQLAnywhereMigration(GenericMigration):
    def migrateColumnDefaultValue(self, state, default_value, source_column, target_column):
        target_catalog = target_column.owner.owner.owner
        target_default_value = default_value

        def raise_on_no_match(re_str, target):
            if re.match(re_str, target) is None:
                raise ValueError('"%s" does not match the regular expression "%s"' % (target, re_str))
            return True

        value_validators = [
            (['TINYINT', 'SMALLINT', 'INTEGER', 'BIGINT'], int),
            (['NUMERIC', 'DECIMAL', 'FLOAT', 'REAL', 'DOUBLE'], float),
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

import re
import string

from wb import DefineModule
import grt

from db_generic_migration_grt import GenericMigration, find_object_with_name

ModuleInfo = DefineModule(name="DbMssqlMigration",
                          author="Oracle Corp.",
                          version="1.0")

# unfinished
MSSQL_COLLATION_MAP = [
    ('SQL_Latin1_General_Cp437_BIN', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp437_CS_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp437_CI_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Pref_CP437_CI_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp437_CI_AI', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp850_BIN', 'utf8_bin', True),
    ('SQL_Latin1_General_Cp850_CS_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp850_CI_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Pref_CP850_CI_AS', 'utf8_general_ci', False),
    ('SQL_Latin1_General_Cp850_CI_AI', 'utf8_general_ci', False),
    ('SQL_1Xcompat_CP850_CI_AS', 'utf8_general_ci', False),
from wb import DefineModule
import grt
from grt import log_warning
import mforms
import traceback
import time
import json

from wb_common import OperationCancelledError

fabric_unavailable_message = ""
fabric_client = ""

ModuleInfo = DefineModule(name="WBFabric",
                          author="Oracle Corp.",
                          version="1.0")


def perform_fabric_operation(conn, name, callback=None, callback_params=None):
    """
    Current Fabric operations are done using the next cycle:
    - Open Connection
    - Execute Specific Operation
    - Close Connection

    This method allows performing these operations using this life cycle, removing from the 
    specific operation the burden of common operations such as password retrieval and exception 
    handling.

    The specific operation should be done on a function received as callback.
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

import random
import os.path

from wb import DefineModule
from workbench import db_driver
from workbench.utils import find_object_with_name
from workbench.exceptions import NotConnectedError

import grt
import SQLEXT as constant

ModuleInfo = DefineModule(name="DbGenericRE",
                          author="Oracle Corp.",
                          version="1.0")


class GenericReverseEngineering(object):
    _connections = {}

    @classmethod
    def check_interruption(cls):
        if grt.query_status():
            raise grt.UserInterrupt()

    @classmethod
    def find_datatype_object(cls, catalog, datatype_name):
        ''' Finds the datatype object corresponding to the given datatype name.
Example #18
0
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 of the
# License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

from wb import DefineModule
import grt

from mforms import Utilities

ModuleInfo = DefineModule(name="WbDocs", author="Oracle", version="1.0")


@ModuleInfo.plugin("wb.docs.open",
                   type="standalone",
                   caption="Open Documentation Library",
                   pluginMenu="Extensions")
@ModuleInfo.export(grt.INT)
def openDocLib():
    Utilities.open_url("http://dev.mysql.com/doc/refman/5.7/en/index.html")
    return 1
Example #19
0
from text_output import TextOutputTab
from run_script import RunScriptForm
from sqlide_catalogman_ext import show_schema_manager
from sqlide_tableman_ext import show_table_inspector

from sqlide_resultset_ext import handleResultsetContextMenu
import sqlide_catalogman_ext
import sqlide_tableman_ext
import sqlide_schematree_ext
import sqlide_import_spatial
import sqlide_power_import_wizard
import sqlide_power_export_wizard

# define this Python module as a GRT module
ModuleInfo = DefineModule(name="SQLIDEUtils",
                          author="Oracle Corp.",
                          version="1.1")


@ModuleInfo.export(grt.INT)
def initialize0():
    nc = NotificationCenter()
    nc.add_observer(handleResultsetContextMenu,
                    name="GRNSQLResultsetMenuWillShow")

    sqlide_schematree_ext.init()

    # register a handler for when the SQLIDE live schema tree context menu is about to be shown
    nc.add_observer(sqlide_schematree_ext.handleLiveTreeContextMenu,
                    name="GRNLiveDBObjectMenuWillShow")  # must be 1st
    nc.add_observer(sqlide_catalogman_ext.handleLiveTreeContextMenu,
Example #20
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

from MySQLGetRequestResult import MySQLGetRequestResult
from HTMLGetData import HTMLGetData
from HTMLParser import HTMLParseError
from wb import DefineModule
import urllib, urllib2, cookielib
import grt, shutil, zipfile, os, mimetypes
from grt import log_info, log_error, log_warning, log_debug

ModuleInfo = DefineModule(name="WbBugReport", author="Oracle", version="1.0")


@ModuleInfo.export(grt.STRING, grt.STRING, grt.STRING, grt.DICT)
def submitBug(user, password, data):
    #Initializes the return value as no error
    ret_val = ''

    try:
        # Creates the object to open and manage the cookies
        cookieJar = cookielib.CookieJar()
        urlOpener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(cookieJar))

        # Attempts to login
        ret_val = login(urlOpener, user, password)