Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 6cd3023

Browse files
committed
Sex Out 7 22:19:05 BRT 2016 Using SQLTools API v0.2.0
1 parent 8e8e70d commit 6cd3023

File tree

5 files changed

+71
-64
lines changed

5 files changed

+71
-64
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![SQLTools](https://github.com/mtxr/SQLTools/raw/images/icon.png?raw=true) SQLTools
1+
![SQLTools v0.5.4](https://github.com/mtxr/SQLTools/raw/images/icon.png?raw=true) SQLTools
22
===============
33

44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9f52b6f590af41c0bce2897d68a60fb6)](https://www.codacy.com/app/matheus-mtxr/SQLTools?utm_source=github.com&utm_medium=referral&utm_content=mtxr/SQLTools&utm_campaign=Badge_Grade)

SQLTools.py

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -388,66 +388,73 @@ def cb(index):
388388
Window().show_quick_panel(history.all(), cb)
389389

390390

391-
# class StSaveQuery(WindowCommand):
392-
# @staticmethod
393-
# def run():
394-
# STM.Storage.promptQueryAlias()
395-
396-
397-
# class StListQueries(WindowCommand):
398-
# @staticmethod
399-
# def run(mode="run"):
400-
# if not ST.conn:
401-
# ST.selectConnection()
402-
# return
403-
404-
# queries = STM.Storage.getSavedQueries().get('queries')
405-
406-
# if len(queries) == 0:
407-
# sublime.message_dialog('No saved queries.')
408-
# return
409-
410-
# options = []
411-
# for alias, query in queries.items():
412-
# options.append([alias, query])
413-
# options.sort()
414-
415-
# def cb(index):
416-
# if index < 0:
417-
# return None
418-
419-
# param2 = output if mode == "run" else options[index][0]
420-
# func = ST.conn.execute if mode == "run" else ST.toNewTab
421-
# return func(options[index][1], param2)
422-
423-
# try:
424-
# Window().show_quick_panel(options, cb)
425-
# except Exception:
426-
# pass
427-
428-
429-
# class StRemoveSavedQuery(WindowCommand):
430-
# @staticmethod
431-
# def run():
432-
# queries = STM.Storage.getSavedQueries().get('queries')
433-
434-
# if len(queries) == 0:
435-
# sublime.message_dialog('No saved queries.')
436-
# return
437-
438-
# queriesArray = []
439-
# for alias, query in queries.items():
440-
# queriesArray.append([alias, query])
441-
# queriesArray.sort()
442-
443-
# def cb(index):
444-
# if index < 0:
445-
# return None
446-
# return STM.Storage.removeQuery(queriesArray[index][0])
447-
# try:
448-
# Window().show_quick_panel(queriesArray, cb)
449-
# except Exception:
450-
# pass
391+
class StSaveQuery(WindowCommand):
392+
@staticmethod
393+
def run():
394+
query = getSelection()
395+
396+
def cb(alias):
397+
queries.add(alias, query)
398+
Window().show_input_panel('Query alias', '', cb, None, None)
399+
400+
401+
class StListQueries(WindowCommand):
402+
@staticmethod
403+
def run(mode="run"):
404+
if not ST.conn:
405+
ST.selectConnection(functionsCallback=lambda: Window().run_command('st_list_queries'))
406+
return
407+
408+
queriesList = queries.all()
409+
if len(queriesList) == 0:
410+
sublime.message_dialog('No saved queries.')
411+
return
412+
413+
options = []
414+
for alias, query in queriesList.items():
415+
options.append([str(alias), str(query)])
416+
options.sort()
417+
418+
def cb(index):
419+
if index < 0:
420+
return None
421+
422+
param2 = output if mode == "run" else options[index][0]
423+
func = ST.conn.execute if mode == "run" else ST.toNewTab
424+
return func(options[index][1], param2)
425+
426+
try:
427+
Window().show_quick_panel(options, cb)
428+
except Exception:
429+
pass
430+
431+
432+
class StRemoveSavedQuery(WindowCommand):
433+
@staticmethod
434+
def run():
435+
if not ST.conn:
436+
ST.selectConnection(functionsCallback=lambda: Window().run_command('st_remove_saved_query'))
437+
return
438+
439+
queriesList = queries.all()
440+
if len(queriesList) == 0:
441+
sublime.message_dialog('No saved queries.')
442+
return
443+
444+
options = []
445+
for alias, query in queriesList.items():
446+
options.append([str(alias), str(query)])
447+
options.sort()
448+
449+
def cb(index):
450+
if index < 0:
451+
return None
452+
453+
return queries.delete(options[index][0])
454+
try:
455+
Window().show_quick_panel(options, cb)
456+
except Exception:
457+
pass
451458

452459

453460
def Window():

SQLToolsAPI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## SQLTools API for plugins - v0.1.0
1+
## SQLTools API for plugins - v0.2.0
22

33
Docs will be ready soon

SQLToolsAPI/Utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "v0.1.0"
1+
__version__ = "v0.2.0"
22

33
import json
44
import os

SQLToolsAPI/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "v0.1.0"
1+
__version__ = "v0.2.0"
22

33

44
__all__ = [

0 commit comments

Comments
 (0)