Revision 2060
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
244 | 244 |
return esc_name_by_module(util.root_module(db.db), name, **kw_args) |
245 | 245 |
|
246 | 246 |
def qual_name(db, schema, table): |
247 |
def esc_name_(name): return esc_name(db, name, preserve_case=True)
|
|
247 |
def esc_name_(name): return esc_name(db, name) |
|
248 | 248 |
table = esc_name_(table) |
249 | 249 |
if schema != None: return esc_name_(schema)+'.'+table |
250 | 250 |
else: return table |
... | ... | |
285 | 285 |
@param table_is_esc Whether the table name has already been escaped |
286 | 286 |
@return tuple(query, params) |
287 | 287 |
''' |
288 |
def esc_name_(name): return esc_name(db, name, preserve_case=True)
|
|
288 |
def esc_name_(name): return esc_name(db, name) |
|
289 | 289 |
|
290 | 290 |
if conds == None: conds = {} |
291 | 291 |
assert limit == None or type(limit) == int |
lib/db_xml.py | ||
---|---|---|
132 | 132 |
place of the column value. |
133 | 133 |
@param commit Whether to commit after each query |
134 | 134 |
''' |
135 |
def qual_name(table): sql.qual_name(db, in_schema, table) |
|
136 |
|
|
135 |
def qual_name(table): return sql.qual_name(db, in_schema, table) |
|
137 | 136 |
def pkey(table): return sql.pkey(db, table, True) |
138 | 137 |
|
139 | 138 |
out_table = name_of(node) |
... | ... | |
152 | 151 |
try: del row[pkey_] |
153 | 152 |
except KeyError: pass |
154 | 153 |
|
154 |
# Divide fields into input columns and literal values |
|
155 |
for out_col, value in row.iteritems(): |
|
156 |
in_col = strings.remove_prefix('$', value) |
|
157 |
if in_col != value: row[out_col] = in_col # value is input column |
|
158 |
else: row[out_col] = (value, out_col) # value is literal value |
|
159 |
|
|
160 |
# Insert node |
|
161 |
out_cols = row.keys() |
|
162 |
map(sql.check_name, out_cols) |
|
163 |
select_query, params = sql.mk_select(db, qual_name(in_table), row.values(), |
|
164 |
table_is_esc=True) |
|
165 |
sql.run_query(db, 'INSERT INTO '+out_table+' ('+', '.join(out_cols)+') ' |
|
166 |
+select_query, params) |
|
167 |
|
|
155 | 168 |
import sys; sys.stderr.write(str(node)) |
156 | 169 |
if commit: db.db.commit() |
157 | 170 |
raise NotImplementedError('By-column optimization not available yet') |
Also available in: Unified diff
Calls to sql.esc_name*(): Removed preserve_case=True because it is now the default