server/sqlutils.py
changeset 2596 d02eed70937f
parent 2512 106b2a05dc88
child 2616 4501ee760eec
equal deleted inserted replaced
2595:e76bf303c6f2 2596:d02eed70937f
    22 
    22 
    23 from cubicweb import Binary, ConfigurationError
    23 from cubicweb import Binary, ConfigurationError
    24 from cubicweb.utils import todate, todatetime
    24 from cubicweb.utils import todate, todatetime
    25 from cubicweb.common.uilib import remove_html_tags
    25 from cubicweb.common.uilib import remove_html_tags
    26 from cubicweb.toolsutils import restrict_perms_to_user
    26 from cubicweb.toolsutils import restrict_perms_to_user
       
    27 from cubicweb.schema import PURE_VIRTUAL_RTYPES
    27 from cubicweb.server import SQL_CONNECT_HOOKS
    28 from cubicweb.server import SQL_CONNECT_HOOKS
    28 from cubicweb.server.utils import crypt_password
    29 from cubicweb.server.utils import crypt_password
    29 
    30 
    30 
    31 
    31 lgc.USE_MX_DATETIME = False
    32 lgc.USE_MX_DATETIME = False
    75     return '\n'.join(output)
    76     return '\n'.join(output)
    76 
    77 
    77 
    78 
    78 def sqlschema(schema, driver, text_index=True,
    79 def sqlschema(schema, driver, text_index=True,
    79               user=None, set_owner=False,
    80               user=None, set_owner=False,
    80               skip_relations=('has_text', 'identity'), skip_entities=()):
    81               skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
    81     """return the system sql schema, according to the given parameters"""
    82     """return the system sql schema, according to the given parameters"""
    82     from yams.schema2sql import schema2sql
    83     from yams.schema2sql import schema2sql
    83     from cubicweb.server.sources import native
    84     from cubicweb.server.sources import native
    84     if set_owner:
    85     if set_owner:
    85         assert user, 'user is argument required when set_owner is true'
    86         assert user, 'user is argument required when set_owner is true'
   100                     skip_relations, skip_entities))
   101                     skip_relations, skip_entities))
   101     return '\n'.join(output)
   102     return '\n'.join(output)
   102 
   103 
   103 
   104 
   104 def sqldropschema(schema, driver, text_index=True,
   105 def sqldropschema(schema, driver, text_index=True,
   105                   skip_relations=('has_text', 'identity'), skip_entities=()):
   106                   skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()):
   106     """return the sql to drop the schema, according to the given parameters"""
   107     """return the sql to drop the schema, according to the given parameters"""
   107     from yams.schema2sql import dropschema2sql
   108     from yams.schema2sql import dropschema2sql
   108     from cubicweb.server.sources import native
   109     from cubicweb.server.sources import native
   109     output = []
   110     output = []
   110     w = output.append
   111     w = output.append