Mercurial > sqlpython
changeset 421:dd9aab264798
mysql logons mostly work
author | catherine@bothari |
---|---|
date | Fri, 20 Nov 2009 13:55:31 -0500 |
parents | eb7cbbb00395 |
children | e728bf6336df |
files | sqlpython/schemagroup.py sqlpython/sqlpyPlus.py |
diffstat | 2 files changed, 7 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/schemagroup.py Thu Nov 19 20:29:08 2009 -0500 +++ b/sqlpython/schemagroup.py Fri Nov 20 13:55:31 2009 -0500 @@ -67,13 +67,14 @@ curs = connection.cursor() curs.execute("""SELECT '%s', current_time""" % username) return curs + # TODO: we just assume that we always need a refresh - that's sloppy class MySQLSchemaAccess(object): child_type = gerald.MySQLSchema - current_database_time_query = 'SELECT sysdate FROM dual' + current_database_time_query = 'SELECT now()' def latest_ddl_timestamp_query(self, username, connection): curs = connection.cursor() - curs.execute("""SELECT '%s', current_time""" % username) + curs.execute("""SELECT '%s', now()""" % username) return curs class SchemaDict(dict):
--- a/sqlpython/sqlpyPlus.py Thu Nov 19 20:29:08 2009 -0500 +++ b/sqlpython/sqlpyPlus.py Fri Nov 20 13:55:31 2009 -0500 @@ -675,8 +675,6 @@ varname = args.lower().split()[0] self.substvars[varname] = self.pseudo_raw_input(prompt) - #TODO: double-ampersand not working - #substvars not remembered b/t queries def ampersand_substitution(self, raw, regexpr, isglobal): subst = regexpr.search(raw) while subst: @@ -1263,6 +1261,7 @@ idx['type'], (idx['unique'] and 'unique') or '') def _str_constraint(self, cons, long=False): + #TODO: this is way too unclear right now if 'condition' in cons: details = '(%s)' % cons['condition'] elif 'reftable' in cons: @@ -1665,53 +1664,9 @@ def do_refs(self, arg): '''Lists referential integrity (foreign key constraints) on an object or referring to it.''' - if not arg.strip(): - self.perror('Usage: refs (table name)') - result = [] - (type, owner, table_name) = self.resolve(arg.upper()) - sql = """SELECT constraint_name, r_owner, r_constraint_name - FROM all_constraints - WHERE constraint_type = 'R' - AND owner = :owner - AND table_name = :table_name""" - self._execute(sql, {"owner": owner, "table_name": table_name}) - for (constraint_name, remote_owner, remote_constraint_name) in self.curs.fetchall(): - result.append('%s on %s.%s:' % (constraint_name, owner, table_name)) - - self._execute("SELECT column_name FROM all_cons_columns WHERE owner = :owner AND constraint_name = :constraint_name ORDER BY position", - {'constraint_name': constraint_name, 'owner': owner}) - result.append(" (%s)" % (",".join(col[0] for col in self.curs.fetchall()))) - self._execute("SELECT table_name FROM all_constraints WHERE owner = :remote_owner AND constraint_name = :remote_constraint_name", - {'remote_owner': remote_owner, 'remote_constraint_name': remote_constraint_name}) - remote_table_name = self.curs.fetchone()[0] - result.append("must be in %s:" % (remote_table_name)) - self._execute("SELECT column_name FROM all_cons_columns WHERE owner = :remote_owner AND constraint_name = :remote_constraint_name ORDER BY position", - {'remote_constraint_name': remote_constraint_name, 'remote_owner': remote_owner}) - result.append(' (%s)\n' % (",".join(col[0] for col in self.curs.fetchall()))) - remote_table_name = table_name - remote_owner = owner - self._execute("""SELECT owner, constraint_name, table_name, r_constraint_name - FROM all_constraints - WHERE (r_owner, r_constraint_name) IN - ( SELECT owner, constraint_name - FROM all_constraints - WHERE table_name = :remote_table_name - AND owner = :remote_owner )""", - {'remote_table_name': remote_table_name, 'remote_owner': remote_owner}) - for (owner, constraint_name, table_name, remote_constraint_name) in self.curs.fetchall(): - result.append('%s on %s.%s:' % (constraint_name, owner, table_name)) - self._execute("SELECT column_name FROM all_cons_columns WHERE owner = :owner AND constraint_name = :constraint_name ORDER BY position", - {'constraint_name': constraint_name, 'owner': owner}) - result.append(" (%s)" % (",".join(col[0] for col in self.curs.fetchall()))) - self._execute("SELECT table_name FROM all_constraints WHERE owner = :remote_owner AND constraint_name = :remote_constraint_name", - {'remote_owner': remote_owner, 'remote_constraint_name': remote_constraint_name}) - remote_table_name = self.curs.fetchone()[0] - result.append("must be in %s:" % (remote_table_name)) - self._execute("SELECT column_name FROM all_cons_columns WHERE owner = :remote_owner AND constraint_name = :remote_constraint_name ORDER BY position", - {'remote_constraint_name': remote_constraint_name, 'remote_owner': remote_owner}) - result.append(' (%s)\n' % (",".join(col[0] for col in self.curs.fetchall()))) - self.poutput('\n'.join(result) + "\n") - + # TODO: needs much polish + return self.do__dir_constraints(arg) + def _test(): import doctest doctest.testmod()