Jump to content

Search the Community

Showing results for tags 'sqlite'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
  • Alfred v2 Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting

Categories

  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Twitter


Website URL


Jabber


Location


Interests

Found 4 results

  1. Transmit 4 Workflow for Alfred app Workflow for searching and opening Favorites in Transmit 4 App. It's really fast, because it reads the SQLite Database or XML datasource in latests releases of Transmit 4. There are already at least 2 Transmit workflows, but one is incompatible with latests Transmit 4 and the other, although very good, uses AppleScript to do the searching, and thus you need to wait for Transmit to open to get feedback. This is particulary slow on non SSD machines. Usage Type the keyword (default ftp) and start typing the name of the favorite to search; dead simple. Installation For OS X 10.9 Mavericks, Download the alfred-transmit.alfredworkflow and import to Alfred 2. For Previous OS X Versions, Download the alfred-transmit.alfredworkflow and import to Alfred 2. Source Code Clone or Fork the Workflow: https://github.com/ramiroaraujo/alfred-transmit-workflow Changelog 2013-12-16 - Released 2014-01-02 - Added support for previous OS versions, using System Ruby 1.8, tested up to Lion 2014-01-03 - Search in both Favorite name and host 2014-01-20 - Added support for Favorites.xml 2014-01-30 - Rebuilt XML search to use different Ruby xml parser Note: I updated the original description to match the project readme file
  2. Is there any way to open the clipboard.alfdb in any terminal program so that I can remove sensitive data and replace it with something like "PASSWORDREMOVED" without corrupting the data file? Is it in any certain data format? Like if it was SQLite I could make the changes through there I know you can do function-backspace to remove entries from the clipboard, however, i just want to remove the sensitive data not the whole line from the clipboard. Thank you, Jared https://jared.nyc https://devopschat.co
  3. I have a few questions regarding workflow structure, storage, and python how-to's. Anki is a flashcard program, it is written in python, and has a sqlite database. 1. In order to connect to the database I need to supply a path. Since I'm using the Anki module alone (without anki's version of PyQt, aqt), I have to supply the path manually. The way I'm doing this is rather costly, and I would like to "store" the path after a successful connection is made, so further instances of the workflow have access to and use this path. Below, I've covered the most likely paths to Anki, but at a later time I would like to ask the user, through Alfred, to input the path if an error occurs. As a point of style, is it customary to import a module within a def? def get_col(): default_locations = [ os.environ['HOME']+'/Anki/User 1/collection.anki2', os.environ['HOME']+'/.anki/User 1/collection.anki2', 'collection.anki2' ] for location in default_locations: if os.path.exists(location): return location else: import glob home_path = os.path.expanduser('~') pattern = (home_path + '/**' + '/Anki' + '/*' + '/collection.anki2') for path in glob.glob(pattern): return path 2. When a result is selected with Alfred, and passed to the next script as the query, how can I get the result of the second script to display in Alfred? The wf.add_item doesn't seem to do it. The script 2, at the end of the post, should display the card count. 3. Besides querying Anki's database, eventually I would like to add cards from Alfred. The flow of the workflow ideally would be to first select a deck, and then options and deck statistics would display below in the results area. One option would be to add a card to the selected deck. After choosing "Add Card" the user would type in the front side, and by some magic of python, the front side text would display as the first result, the input area would clear and allow for the backside to be entered, which would display as the second result before submitting the change. This is why I'm asking for suggestions for structure. Is there a best way to account for these options by structuring the workflow a particular way? Further down the road I could allow for changes to the front or back after the initial input so that mistakes on card entry could be corrected. And much further down, I could allow for images to be attached with Alfred's file action. I've been playing with Anki heavily, I've authored a addon, HTML 2 ANKI (repo), and generally feel confident to start merging what I've learned into an Alfred workflow. 4. Within the workflow I've supplied the Anki module, but to import the module I first have to append the path with sys.path.append, else I receive errors, or run the script from the Anki folder. I did make sure to include __init__.py in all subfolders, however, the Anki module's __init__.py is not empty, and this seems to be the source of my frustration. I won't need the module until I start adding cards with Alfred (Anki says that doing it through the database is not recommended, mentioning that when updating Anki issues may arise), but I wanted to know if appending the path is acceptable here. I'll be sitting for step1 this summer, so I'm just trying to form a plan at this point, but afterwards I'd like to get this going. Anki's popular for people learning new languages, and med students, so I'm hoping it will be of use for a few people. As always suggestions are most appreciated. Script 1: # -*- coding: utf-8 -*- # [Run from subdirectory] import os, sys #abspath = os.path.abspath(__file__) #dname = os.path.dirname(abspath) + '/main' #sys.path.append(dname) # [IMPORT] import re import sqlite3 import json #from anki import storage, stats #from BeautifulSoup import BeautifulSoup, Comment, NavigableString from workflow import Workflow log = None def get_col(): default_locations = [ os.environ['HOME']+'/Anki/User 1/collection.anki2', os.environ['HOME']+'/.anki/User 1/collection.anki2', 'collection.anki2' ] for location in default_locations: if os.path.exists(location): return location else: import glob home_path = os.path.expanduser('~') pattern = (home_path + '/**' + '/Anki' + '/*' + '/collection.anki2') for path in glob.glob(pattern): return path return None def db_decks(db): results =[] deck_db = db.execute("SELECT decks FROM col") decks = json.loads(deck_db.fetchone()[0]) for d in decks.items(): deck = {'title': None, 'id': None} deck['title'] = d[1]['name'] deck['id'] = d[0] log.debug(deck) if deck['id'] is None: continue results.append(deck) return results def key_for_deck(deck): return '{} {}'.format(deck['title'], deck['id']) def main(wf): query = None if len(wf.args): query = wf.args[0] apath = get_col() connection = sqlite3.connect(apath) decks = db_decks(connection) if query: decks = wf.filter(query, decks, key_for_deck) if not decks: wf.add_item('No items', icon=ICON_WARNING) for deck in decks: wf.add_item( title = deck['title'], subtitle = deck['id'], arg = deck['id'] + ' ' + deck['title'] + ' ' + apath, valid = True, icon = 'icon.png') wf.send_feedback() if __name__ == '__main__': wf = Workflow() log = wf.logger sys.exit(wf.run(main)) Script 2: 1. How can I get it's result to display in Alfred? 2. With very large decks (many cards), I get an error saying so, I'm thinking this is the sqlite, ideas? # -*- coding: utf-8 -*- import os, sys, re import sqlite3, json from workflow import Workflow log = None def db_cards(db, did): cards_did = db.execute("SELECT COUNT(*) " "FROM cards " "WHERE cards.did = ?", (did,) ) card_count = cards_did.fetchone() result = card_count[0] return result def main(wf): did, d_title, apath = wf.args[0].split() connection = sqlite3.connect(apath) count = db_cards(connection, did) wf.add_item( title=d_title, subtitle=unicode(count), arg=did, valid=True, icon='icon.png') wf.send_feedback() if __name__ == '__main__': wf = Workflow() log = wf.logger sys.exit(wf.run(main))
  4. I've started work on a workflow bundle that I intend to use as a base for other scripting workflows. The language I'm most proficient in is Ruby, so I've taken the liberty of creating this for myself and others to use when developing in Ruby. Features: Shows exceptions and debug output in the Mac OS X Console Adds a ruby gems repository to the workflow bundle so you can package gems with your workflow. Provides access to the workflow bundle's info.plist data Provides sqlite3 gem It's incomplete, but I wanted to get feedback from others as soon as possible. For example, I've added a compiled sqlite3 gem in as part of the gem repository. Does this work across Mac systems? i.e. if you install the workflow, do you get sqlite3 support out-of-the-box? To get started: Copy the init.rb.example file into your script window (e.g. Run Script action). Choose /usr/bin/ruby as the script language. The contents of init.rb.example is some "bootstrap" ruby code that takes great care to catch all exceptions and send them to the Console.app so you can debug your scripts. Copy alfred.rb and main.rb to your bundle. Also copy ruby-1.8 and its subdirectories. This is the gem repo that will let you install gems as part of the bundle for others to use. https://github.com/canadaduane/alfred2-ruby-framework Thanks, Duane Johnson http://makerhome.ca/
×
×
  • Create New...