本文整理汇总了Python中pyrseas.dbobject.quote_id函数的典型用法代码示例。如果您正苦于以下问题:Python quote_id函数的具体用法?Python quote_id怎么用?Python quote_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quote_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
示例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)
示例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 '')]
示例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
示例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 '')]
示例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
示例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 '')]
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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