1 2 3 4 5 6 7 8 9 10 | def _object_to_query(obj):
values = [(f, '\'%s\'' % f.get_db_prep_save(f.value_from_object(obj))) for f in obj._meta.local_fields]
q = sql.InsertQuery(obj)
q.insert_values(values)
compiler = q.get_compiler('default')
# Normally, execute sets this, but we don't want to call execute
setattr(compiler, 'return_id', False)
stmt, params = compiler.as_sql()
stmt = stmt % params
return stmt
|
More like this
- Bulk Insert - updated 5/9/2008 by coolie 5 years, 8 months ago
- MySQL "Text" Type Model Field by blackbrrr 5 years ago
- Arbitrary auto-generated primary keys by gsakkis 2 years, 11 months ago
- Changing field type in production by lawgon 6 years, 2 months ago
- PowerDNS models by diverman 4 years ago
Comments