本文整理汇总了Python中pyrseas.dbobject.quote_id函数的典型用法代码示例。如果您正苦于以下问题:Python quote_id函数的具体用法?Python quote_id怎么用?Python quote_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quote_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: identifier
def identifier(self):
"""Return a full identifier for a user mapping object
:return: string
"""
return "FOR %s SERVER %s" % (
self.username == 'PUBLIC' and 'PUBLIC' or quote_id(self.username),
quote_id(self.server))
开发者ID:court-jus,项目名称:Pyrseas,代码行数:8,代码来源:foreign.py
示例2: get_attrs
def get_attrs(self, dbconn):
"""Get the attributes for the sequence
:param dbconn: a DbConnection object
"""
data = dbconn.fetchone(
"""SELECT start_value, increment_by, max_value, min_value,
cache_value
FROM %s.%s""" % (quote_id(self.schema), quote_id(self.name)))
for key, val in data.items():
setattr(self, key, val)
开发者ID:rdunklau,项目名称:Pyrseas,代码行数:11,代码来源:table.py
示例3: create
def create(self):
"""Return SQL statements to CREATE the user mapping
:return: SQL statements
"""
options = []
if hasattr(self, 'options'):
options.append(self.options_clause())
return ["CREATE USER MAPPING FOR %s\n SERVER %s%s" % (
self.username == 'PUBLIC' and 'PUBLIC' or
quote_id(self.username), quote_id(self.server),
options and '\n ' + ',\n '.join(options) or '')]
开发者ID:court-jus,项目名称:Pyrseas,代码行数:12,代码来源:foreign.py
示例4: set_sequence_default
def set_sequence_default(self):
"""Return SQL statements to set a nextval() DEFAULT
:return: list of SQL statements
"""
stmts = []
pth = self.set_search_path()
if pth:
stmts.append(pth)
stmts.append("ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s" % (
quote_id(self.table), quote_id(self.name), self.default))
return stmts
开发者ID:PJMODOS,项目名称:Pyrseas,代码行数:12,代码来源:column.py
示例5: create
def create(self):
"""Return SQL statements to CREATE the extension
:return: SQL statements
"""
opt_clauses = []
if hasattr(self, 'schema') and self.schema != 'public':
opt_clauses.append("SCHEMA %s" % quote_id(self.schema))
if hasattr(self, 'version'):
opt_clauses.append("VERSION '%s'" % self.version)
return ["CREATE EXTENSION %s%s" % (
quote_id(self.name), ('\n ' + '\n '.join(opt_clauses))
if opt_clauses else '')]
开发者ID:court-jus,项目名称:Pyrseas,代码行数:13,代码来源:extension.py
示例6: add_owner
def add_owner(self):
"""Return statement to ALTER the sequence to indicate its owner table
:return: SQL statement
"""
stmts = []
pth = self.set_search_path()
if pth:
stmts.append(pth)
stmts.append("ALTER SEQUENCE %s OWNED BY %s.%s" % (
quote_id(self.name), quote_id(self.owner_table),
quote_id(self.owner_column)))
return stmts
开发者ID:rdunklau,项目名称:Pyrseas,代码行数:13,代码来源:table.py
示例7: create
def create(self):
"""Return SQL statements to CREATE the extension
:return: SQL statements
"""
opt_clauses = []
if self.schema is not None and self.schema not in (
'pg_catalog', 'public'):
opt_clauses.append("SCHEMA %s" % quote_id(self.schema))
if self.version is not None:
opt_clauses.append("VERSION '%s'" % self.version)
return ["CREATE EXTENSION %s%s" % (
quote_id(self.name), ('\n ' + '\n '.join(opt_clauses))
if opt_clauses else '')]
开发者ID:conor1984,项目名称:Pyrseas,代码行数:14,代码来源:extension.py
示例8: diff_map
def diff_map(self, inpk):
"""Generate SQL to transform an existing primary key
:param inpk: a YAML map defining the new primary key
:return: list of SQL statements
Compares the primary key to an input primary key and generates
SQL statements to transform it into the one represented by the
input.
"""
stmts = []
# TODO chompare column names
if self.col_idx != inpk.col_idx:
stmts.append(self.drop())
stmts.append(inpk.add())
elif hasattr(inpk, 'cluster'):
if not hasattr(self, 'cluster'):
stmts.append("CLUSTER %s USING %s" % (
self._table.qualname(), quote_id(self.name)))
elif hasattr(self, 'cluster'):
stmts.append("ALTER TABLE %s\n SET WITHOUT CLUSTER" %
self._table.qualname())
stmts.append(self.diff_description(inpk))
return stmts
开发者ID:segmond,项目名称:Pyrseas,代码行数:25,代码来源:constraint.py
示例9: create
def create(self):
"""Return SQL statements to CREATE the trigger
:return: SQL statements
"""
stmts = []
constr = defer = ''
if hasattr(self, 'constraint') and self.constraint:
constr = "CONSTRAINT "
if hasattr(self, 'deferrable') and self.deferrable:
defer = "DEFERRABLE "
if hasattr(self, 'initially_deferred') and self.initially_deferred:
defer += "INITIALLY DEFERRED"
if defer:
defer = '\n ' + defer
evts = " OR ".join(self.events).upper()
if hasattr(self, 'columns') and 'update' in self.events:
evts = evts.replace("UPDATE", "UPDATE OF %s" % (
", ".join(self.columns)))
cond = ''
if hasattr(self, 'condition'):
cond = "\n WHEN (%s)" % self.condition
stmts.append("CREATE %sTRIGGER %s\n %s %s ON %s%s\n FOR EACH %s"
"%s\n EXECUTE PROCEDURE %s" % (
constr, quote_id(self.name), self.timing.upper(), evts,
self._table.qualname(), defer,
self.level.upper(), cond, self.procedure))
if hasattr(self, 'description'):
stmts.append(self.comment())
return stmts
开发者ID:PJMODOS,项目名称:Pyrseas,代码行数:30,代码来源:trigger.py
示例10: diff_map
def diff_map(self, inindex):
"""Generate SQL to transform an existing index
:param inindex: a YAML map defining the new index
:return: list of SQL statements
Compares the index to an input index and generates SQL
statements to transform it into the one represented by the
input.
"""
stmts = []
if not hasattr(self, 'unique'):
self.unique = False
if self.access_method != inindex.access_method \
or self.unique != inindex.unique:
stmts.append("DROP INDEX %s" % self.qualname())
self.access_method = inindex.access_method
self.unique = inindex.unique
stmts.append(self.create())
# TODO: need to deal with changes in keycols
base = "ALTER INDEX %s\n " % self.qualname()
if hasattr(inindex, 'tablespace'):
if not hasattr(self, 'tablespace') \
or self.tablespace != inindex.tablespace:
stmts.append(base + "SET TABLESPACE %s"
% quote_id(inindex.tablespace))
elif hasattr(self, 'tablespace'):
stmts.append(base + "SET TABLESPACE pg_default")
stmts.append(self.diff_description(inindex))
return stmts
开发者ID:comel,项目名称:Pyrseas,代码行数:31,代码来源:index.py
示例11: create
def create(self):
"""Return a SQL statement to CREATE the index
:return: SQL statements
"""
stmts = []
pth = self.set_search_path()
if pth:
stmts.append(pth)
unq = hasattr(self, 'unique') and self.unique
acc = hasattr(self, 'access_method') \
and 'USING %s ' % self.access_method or ''
stmts.append("CREATE %sINDEX %s ON %s %s(%s)" % (
unq and 'UNIQUE ' or '', quote_id(self.name), quote_id(self.table),
acc, hasattr(self, 'keycols') and self.key_columns() or
self.expression))
return stmts
开发者ID:PJMODOS,项目名称:Pyrseas,代码行数:17,代码来源:index.py
示例12: create
def create(self):
"""Return SQL statements to CREATE the user mapping
:return: SQL statements
"""
options = []
if hasattr(self, 'options'):
opts = []
for opt in self.options:
(nm, val) = opt.split('=')
opts.append("%s '%s'" % (nm, val))
options.append("OPTIONS (%s)" % ', '.join(opts))
stmts = ["CREATE USER MAPPING FOR %s\n SERVER %s%s" % (
self.username == 'PUBLIC' and 'PUBLIC' or
quote_id(self.username), quote_id(self.server),
options and '\n ' + ',\n '.join(options) or '')]
return stmts
开发者ID:rdunklau,项目名称:Pyrseas,代码行数:17,代码来源:foreign.py
示例13: create
def create(self):
"""Return SQL statements to CREATE the schema
:return: SQL statements
"""
stmts = ["CREATE SCHEMA %s" % quote_id(self.name)]
if hasattr(self, "description"):
stmts.append(self.comment())
return stmts
开发者ID:PJMODOS,项目名称:Pyrseas,代码行数:9,代码来源:schema.py
示例14: create
def create(self):
"""Return SQL statements to CREATE the language
:return: SQL statements
"""
stmts = ["CREATE LANGUAGE %s" % quote_id(self.name)]
if hasattr(self, 'description'):
stmts.append(self.comment())
return stmts
开发者ID:pombredanne,项目名称:Pyrseas,代码行数:9,代码来源:language.py
示例15: set_sequence_default
def set_sequence_default(self):
"""Return SQL statements to set a nextval() DEFAULT
:return: list of SQL statements
"""
stmts = []
stmts.append("ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s" % (
self.qualname(self.table), quote_id(self.name), self.default))
return stmts
开发者ID:conor1984,项目名称:Pyrseas,代码行数:9,代码来源:column.py
示例16: qualname
def qualname(self):
"""Return the schema-qualified name of the operator
:return: string
No qualification is used if the schema is 'public'.
"""
return self.schema == 'public' and self.name \
or "%s.%s" % (quote_id(self.schema), self.name)
开发者ID:pombredanne,项目名称:Pyrseas,代码行数:9,代码来源:operator.py
示例17: add_owner
def add_owner(self):
"""Return statement to ALTER the sequence to indicate its owner table
:return: SQL statement
"""
stmts = []
stmts.append("ALTER SEQUENCE %s OWNED BY %s.%s" % (
self.qualname(), self.qualname(self.owner_table),
quote_id(self.owner_column)))
return stmts
开发者ID:pau,项目名称:Pyrseas,代码行数:10,代码来源:table.py
示例18: create
def create(self):
"""Return SQL statements to CREATE the event trigger
:return: SQL statements
"""
filter = ''
if hasattr(self, 'tags'):
filter = "\n WHEN tag IN (%s)" % ", ".join(
["'%s'" % tag for tag in self.tags])
return ["CREATE %s %s\n ON %s%s\n EXECUTE PROCEDURE %s" % (
self.objtype, quote_id(self.name), self.event, filter,
self.procedure)]
开发者ID:conor1984,项目名称:Pyrseas,代码行数:12,代码来源:eventtrig.py
示例19: create
def create(self):
"""Return a SQL statement to CREATE the index
:return: SQL statements
"""
stmts = []
pth = self.set_search_path()
if pth:
stmts.append(pth)
unq = hasattr(self, 'unique') and self.unique
acc = hasattr(self, 'access_method') \
and 'USING %s ' % self.access_method or ''
tblspc = ''
if hasattr(self, 'tablespace'):
tblspc = '\n TABLESPACE %s' % self.tablespace
stmts.append("CREATE %sINDEX %s ON %s %s(%s)%s" % (
'UNIQUE ' if unq else '', quote_id(self.name),
quote_id(self.table), acc, self.key_expressions(), tblspc))
if hasattr(self, 'description'):
stmts.append(self.comment())
return stmts
开发者ID:comel,项目名称:Pyrseas,代码行数:21,代码来源:index.py
示例20: diff_map
def diff_map(self, inuc):
"""Generate SQL to transform an existing unique constraint
:param inuc: a YAML map defining the new unique constraint
:return: list of SQL statements
Compares the unique constraint to an input unique constraint
and generates SQL statements to transform it into the one
represented by the input.
"""
stmts = []
# TODO: to be implemented (via ALTER DROP and ALTER ADD)
if hasattr(inuc, 'cluster'):
if not hasattr(self, 'cluster'):
stmts.append("CLUSTER %s USING %s" % (
quote_id(self.table), quote_id(self.name)))
elif hasattr(self, 'cluster'):
stmts.append("ALTER TABLE %s\n SET WITHOUT CLUSTER" %
quote_id(self.table))
stmts.append(self.diff_description(inuc))
return stmts
开发者ID:court-jus,项目名称:Pyrseas,代码行数:21,代码来源:constraint.py
注:本文中的pyrseas.dbobject.quote_id函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论