コード例 #1
0
ファイル: oraschemademo.py プロジェクト: ktosiu/scratchbox
def dropSchema(app, conn):
   r = dbschema.getSchemaVersion(conn, oraschema.LATESTVERSIONS)

   if r['schema-version'] is None:
      raise Exception("crossbar.io Demo not installed")

   return _setupSchema(app, conn, uninstallOnly = True)
コード例 #2
0
ファイル: oraschemademo.py プロジェクト: ktosiu/scratchbox
def setupSchema(app, conn):
   r = dbschema.getSchemaVersion(conn, oraschema.LATESTVERSIONS)

   if r['schema-version'] is not None:
      raise Exception("crossbar.io Demo already installed")

   return _setupSchema(app, conn)
コード例 #3
0
ファイル: oraschemademo.py プロジェクト: ktosiu/scratchbox
def upgradeSchema(app, conn):
   r = dbschema.getSchemaVersion(conn, oraschema.LATESTVERSIONS)

   if r['schema-version'] is None:
      raise Exception("crossbar.io Demo not installed")

   if not r['schema-needs-upgrade']:
      raise Exception("crossbar.io Demo needs no upgrade")

   return _setupSchema(app, conn)
コード例 #4
0
ファイル: oraschema.py プロジェクト: ktosiu/scratchbox
def getDatabaseInfo(app, conn):
    """
   Get database information.
   """
    cur = conn.cursor()

    ## this information should be accessible by any user that can CONNECT
    ##
    cur.execute("""SELECT systimestamp AT TIME ZONE 'UTC',
                         (SELECT version FROM product_component_version WHERE product LIKE 'Oracle%' AND rownum < 2) AS product_version,
                         (SELECT * FROM v$version WHERE banner LIKE 'Oracle%' AND rownum < 2) AS product_version_str,
                         sys_context('USERENV', 'CURRENT_SCHEMA')
                  FROM dual""")

    rr = cur.fetchone()
    current_time = rr[0]
    version_str = str(rr[1]).strip()
    version = str(rr[2]).strip()
    current_schema = rr[3]

    ## the following seems to require "SELECT ANY DICTIONARY" grant
    ##
    try:
        cur.execute("SELECT startup_time FROM sys.v_$instance")
        rr = cur.fetchone()
        start_time = rr[0]
    except:
        start_time = None

    ## the following seems to require "SELECT ANY DICTIONARY" grant
    ##
    try:
        cur.execute("SELECT dbid FROM v$database")
        rr = cur.fetchone()
        sysuuid = str(rr[0]).strip()
    except:
        sysuuid = None

    dbinfo = {
        'current-schema': current_schema,
        # FIXME!!
        #'current-time': current_time,
        #'start-time': start_time,
        'current-time': None,
        'start-time': None,
        'version': version,
        'version-string': version_str,
        'uuid': sysuuid
    }

    schemainfo = dbschema.getSchemaVersion(conn, LATESTVERSIONS)

    return {'database': dbinfo, 'schema': schemainfo}
コード例 #5
0
def getDatabaseInfo(app, conn):
   """
   Get database information.
   """
   cur = conn.cursor()

   ## this information should be accessible by any user that can CONNECT
   ##
   cur.execute("""SELECT systimestamp AT TIME ZONE 'UTC',
                         (SELECT version FROM product_component_version WHERE product LIKE 'Oracle%' AND rownum < 2) AS product_version,
                         (SELECT * FROM v$version WHERE banner LIKE 'Oracle%' AND rownum < 2) AS product_version_str,
                         sys_context('USERENV', 'CURRENT_SCHEMA')
                  FROM dual""")

   rr = cur.fetchone()
   current_time = rr[0]
   version_str = str(rr[1]).strip()
   version = str(rr[2]).strip()
   current_schema = rr[3]

   ## the following seems to require "SELECT ANY DICTIONARY" grant
   ##
   try:
      cur.execute("SELECT startup_time FROM sys.v_$instance")
      rr = cur.fetchone()
      start_time = rr[0]
   except:
      start_time = None

   ## the following seems to require "SELECT ANY DICTIONARY" grant
   ##
   try:
      cur.execute("SELECT dbid FROM v$database")
      rr = cur.fetchone()
      sysuuid = str(rr[0]).strip()
   except:
      sysuuid = None

   dbinfo = {'current-schema': current_schema,
             # FIXME!!
             #'current-time': current_time,
             #'start-time': start_time,
             'current-time': None,
             'start-time': None,
             'version': version,
             'version-string': version_str,
             'uuid': sysuuid}

   schemainfo = dbschema.getSchemaVersion(conn, LATESTVERSIONS)

   return {'database': dbinfo, 'schema': schemainfo}
コード例 #6
0
ファイル: oraschemademo.py プロジェクト: ktosiu/scratchbox
def getSchemaVersion(app, conn):
   return dbschema.getSchemaVersion(conn, oraschema.LATESTVERSIONS)