Example #1
0
 def process_remainder(self, remainder):
     column_names = set()
     if len(remainder) == 0:
         return
     for table in self.database.tables_metadata.values():
         column_names |= set(table.columns.keys())
     if "catsql_database_url" in column_names:
         column_names.remove("catsql_database_url")
     parser = argparse.ArgumentParser()
     cmdline.add_options(parser)
     for name in sorted(column_names):
         try:
             parser.add_argument("--{}".format(name), nargs=1, default=None)
         except argparse.ArgumentError:
             column_names.remove(name)
     self.values = vars(parser.parse_args(self.sys_args))
     dud = []
     for key, val in self.values.items():
         if (key not in column_names) or val is None:
             dud.append(key)
     for key in dud:
         del self.values[key]
     for key, val in self.values.items():
         self.values[key] = val[0]
         self.context_columns.add(key)
Example #2
0
 def process_remainder(self, remainder):
     column_names = set()
     if len(remainder) == 0:
         return
     for table in self.database.tables_metadata.values():
         keys = None
         if hasattr(table, 'columns'):
             keys = table.columns.keys()
         else:
             keys = table.keys
         column_names |= set(keys)
     if 'catsql_database_url' in column_names:
         column_names.remove('catsql_database_url')
     parser = argparse.ArgumentParser()
     cmdline.add_options(parser)
     for name in sorted(column_names):
         try:
             parser.add_argument('--{}'.format(name), nargs=1, default=None)
         except argparse.ArgumentError:
             column_names.remove(name)
     self.values = vars(parser.parse_args(self.sys_args))
     dud = []
     for key, val in self.values.items():
         if (key not in column_names) or val is None:
             dud.append(key)
     for key in dud:
         del self.values[key]
     for key, val in self.values.items():
         self.values[key] = val[0]
         self.context_columns.add(key)
Example #3
0
def catsql(sys_args):

    parser = argparse.ArgumentParser(
        description="Quickly display and edit a slice of a database.", formatter_class=SmartFormatter
    )

    cmdline.add_options(parser)
    args, remainder = parser.parse_known_args(sys_args)
    viewer = Viewer(args, remainder, sys_args)
    viewer.show()
Example #4
0
def catsql(sys_args):

    parser = argparse.ArgumentParser(
        description='Quickly display and edit a slice of a database.',
        formatter_class=SmartFormatter)

    cmdline.add_options(parser)
    args, remainder = parser.parse_known_args(sys_args)
    viewer = Viewer(args, remainder, sys_args)
    viewer.show()