What is an efficient way of inserting thousands of records into an SQLite table using Django?

You want to check out django.db.transaction.commit_manually. http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-db-transaction-commit-manually So it would be something like: from django.db import transaction @transaction.commit_manually def viewfunc(request): … for item in items: entry = Entry(a1=item.a1, a2=item.a2) entry.save() transaction.commit() Which will only commit once, instead at each save(). In django 1.3 context managers were introduced. So now you can use transaction.commit_on_success() in a … Read more

SQL Server: Cannot insert an explicit value into a timestamp column

According to MSDN, timestamp Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time. To record … Read more

How to insert an item into a key/value pair object?

List<KeyValuePair<string, string>> kvpList = new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>(“Key1”, “Value1”), new KeyValuePair<string, string>(“Key2”, “Value2”), new KeyValuePair<string, string>(“Key3”, “Value3”), }; kvpList.Insert(0, new KeyValuePair<string, string>(“New Key 1”, “New Value 1”)); Using this code: foreach (KeyValuePair<string, string> kvp in kvpList) { Console.WriteLine(string.Format(“Key: {0} Value: {1}”, kvp.Key, kvp.Value); } the expected output should be: Key: New Key … Read more

Bulk/batch update/upsert in PostgreSQL

Bulk insert You can modify the bulk insert of three columns by @Ketema: INSERT INTO “table” (col1, col2, col3) VALUES (11, 12, 13) , (21, 22, 23) , (31, 32, 33); It becomes: INSERT INTO “table” (col1, col2, col3) VALUES (unnest(array[11,21,31]), unnest(array[12,22,32]), unnest(array[13,23,33])) Replacing the values with placeholders: INSERT INTO “table” (col1, col2, col3) VALUES … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)