server/sqlutils.py
changeset 10200 cceb2c7c02f4
parent 10125 bc6461a7d2da
child 10205 737271ffe407
equal deleted inserted replaced
10199:218c28bff695 10200:cceb2c7c02f4
   101               text_index=True, set_owner=True,
   101               text_index=True, set_owner=True,
   102               skip_relations=(), skip_entities=()):
   102               skip_relations=(), skip_entities=()):
   103     """return sql to give all access privileges to the given user on the system
   103     """return sql to give all access privileges to the given user on the system
   104     schema
   104     schema
   105     """
   105     """
   106     from yams.schema2sql import grant_schema
   106     from cubicweb.server.schema2sql import grant_schema
   107     from cubicweb.server.sources import native
   107     from cubicweb.server.sources import native
   108     output = []
   108     output = []
   109     w = output.append
   109     w = output.append
   110     w(native.grant_schema(user, set_owner))
   110     w(native.grant_schema(user, set_owner))
   111     w('')
   111     w('')
   119 
   119 
   120 def sqlschema(schema, driver, text_index=True,
   120 def sqlschema(schema, driver, text_index=True,
   121               user=None, set_owner=False,
   121               user=None, set_owner=False,
   122               skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
   122               skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
   123     """return the system sql schema, according to the given parameters"""
   123     """return the system sql schema, according to the given parameters"""
   124     from yams.schema2sql import schema2sql
   124     from cubicweb.server.schema2sql import schema2sql
   125     from cubicweb.server.sources import native
   125     from cubicweb.server.sources import native
   126     if set_owner:
   126     if set_owner:
   127         assert user, 'user is argument required when set_owner is true'
   127         assert user, 'user is argument required when set_owner is true'
   128     output = []
   128     output = []
   129     w = output.append
   129     w = output.append
   144 
   144 
   145 
   145 
   146 def sqldropschema(schema, driver, text_index=True,
   146 def sqldropschema(schema, driver, text_index=True,
   147                   skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
   147                   skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
   148     """return the sql to drop the schema, according to the given parameters"""
   148     """return the sql to drop the schema, according to the given parameters"""
   149     from yams.schema2sql import dropschema2sql
   149     from cubicweb.server.schema2sql import dropschema2sql
   150     from cubicweb.server.sources import native
   150     from cubicweb.server.sources import native
   151     output = []
   151     output = []
   152     w = output.append
   152     w = output.append
   153     if text_index:
   153     if text_index:
   154         dbhelper = db.get_db_helper(driver)
   154         dbhelper = db.get_db_helper(driver)