Exemple #1
0
def main(argv):
        """Main entry function for CLI script, should be
        passed CLI args tuple, normally from sys.argv
        """
        # Get CLI options
        try:
                opts, args = getopt.getopt(
                        argv,
                        "d:",
                        [
                                "dsn=",
                        ]
                )
        except getopt.GetoptError:
                error("Unknown options", True, USAGE_MESSAGE)

        if not opts:
                usage(USAGE_MESSAGE)
                sys.exit(0)

        dsn = None

        # Parse CLI options
        for opt, arg in opts:
                if opt in ("-d", "--dsn"):
                        dsn = arg
        if not dsn:
                error("Please provide a DSN", True, USAGE_MESSAGE)

        # Setup cursor
        conn = pyodbc.connect(dsn)

        u = ODBCUtility()
        u.cursor = u.system_cursor = conn.cursor()
        u.cmdloop()
Exemple #2
0
def main(argv):
        """Main entry function for CLI script, should be
        passed CLI args tuple, normally from sys.argv
        """
        # Get CLI options
        try:
                opts, args = getopt.getopt(
                        argv,
                        "f:",
                        [
                                "file=",
                        ]
                )
        except getopt.GetoptError:
                error("Unknown options", True, USAGE_MESSAGE)

        if not opts:
                usage(USAGE_MESSAGE)
                sys.exit(0)

        filepath = None

        # Parse CLI options
        for opt, arg in opts:
                if opt in ("-f", "--file"):
                        filepath = arg
        if not filepath:
                error("Please provide a DB filepath", True, USAGE_MESSAGE)

        # Setup cursor
        conn = sqlite3.connect(filepath)

        u = LiteUtility()
        u.cursor = u.system_cursor = conn.cursor()
        u.cmdloop()