-
Notifications
You must be signed in to change notification settings - Fork 6k
Microsoft.Data.Sqlite content improvements #16361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
--- | ||
title: Online Backup | ||
title: Online backup | ||
ms.date: 12/13/2019 | ||
description: Learn how to use SQLite's online backup feature. | ||
--- | ||
# Online Backup | ||
# Online backup | ||
|
||
SQLite can back up database files while the app is running. This functionality is available in Microsoft.Data.Sqlite as the [BackupDatabase](/dotnet/api/microsoft.data.sqlite.sqliteconnection.backupdatabase) method on SqliteConnection. | ||
SQLite can back up database files while the app is running. This functionality is available in Microsoft.Data.Sqlite as the <xref:Microsoft.Data.Sqlite.SqliteConnection.BackupDatabase%2A> method on `SqliteConnection`. | ||
|
||
[!code-csharp[](../../../../samples/snippets/standard/data/sqlite/BackupSample/Program.cs?name=snippet_Backup)] | ||
|
||
Currently, BackupDatabase will back up the database as quickly as possible blocking other connections from writing to the database. Issue [#13834](https://github.com/aspnet/EntityFrameworkCore/issues/13834) would provide an alternative API to back up the database in the background allowing other connections to interrupt the backup and write to the database. If you're interested, please provide feedback on the issue. | ||
Currently, `BackupDatabase` will back up the database as quickly as possible and blocks other connections from writing to the database. Issue [#13834](https://github.com/aspnet/EntityFrameworkCore/issues/13834) would provide an alternative API to back up the database in the background and allow other connections to interrupt the backup and write to the database. If you're interested, provide feedback on the issue. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
--- | ||
title: BLOB I/O | ||
title: Blob I/O | ||
ms.date: 12/13/2019 | ||
description: Learn how to use SQLite's BLOB I/O feature. | ||
--- | ||
# BLOB I/O | ||
# Blob I/O | ||
|
||
You can reduce memory usage while reading and writing large objects by streaming the data into and out of the database. This can be especially useful when parsing or transforming the data. | ||
|
||
Start by inserting a row as normal. Use the zeroblob() SQL function to allocate space in the database to hold the large object. The last_insert_rowid() function provides a convenient way to get its rowid. | ||
Start by inserting a row as normal. Use the `zeroblob()` SQL function to allocate space in the database to hold the large object. The `last_insert_rowid()` function provides a convenient way to get its rowid. | ||
|
||
mairaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[!code-csharp[](../../../../samples/snippets/standard/data/sqlite/StreamingSample/Program.cs?name=snippet_Insert)] | ||
|
||
After inserting the row, open a stream to write the large object using [SqliteBlob](/dotnet/api/microsoft.data.sqlite.sqliteblob). | ||
After inserting the row, open a stream to write the large object using <xref:Microsoft.Data.Sqlite.SqliteBlob>. | ||
|
||
[!code-csharp[](../../../../samples/snippets/standard/data/sqlite/StreamingSample/Program.cs?name=snippet_Write)] | ||
|
||
To stream the large object out of the database, you must select the rowid or one of its aliases as show here in addition to the large object's column. If you don't select the rowid, the entire object will be loaded into memory. The object returned by GetStream() will be a SqliteBlob when done correctly. | ||
To stream the large object out of the database, you must select the rowid or one of its aliases as show here in addition to the large object's column. If you don't select the rowid, the entire object will be loaded into memory. The object returned by `GetStream()` will be a `SqliteBlob` when done correctly. | ||
|
||
[!code-csharp[](../../../../samples/snippets/standard/data/sqlite/StreamingSample/Program.cs?name=snippet_Read)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
title: Bulk Insert | ||
title: Bulk insert | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a very short article @bricelam. I'd consider moving this into another article. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of people ask how to do bulk insert. This is just a page for them to find saying you don’t have to do anything special on SQLite. I think if we add a bit more context of what bulk insert is on other databases, how it speeds things up and why it doesn’t apply to SQLite it would be a better article. Also maybe it could use some more details on how these two steps help speed things up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But maybe it can also merge into the ADO.NET limitations |
||
ms.date: 12/13/2019 | ||
description: Performance tips you can use when making a lot of changes to the database. | ||
description: Performance tips you can use when making numerous changes to the database. | ||
--- | ||
# Bulk Insert | ||
# Bulk insert | ||
|
||
SQLite doesn't have any special way to bulk insert data. To get optimal performance when inserting or updating data, ensure that you do the following. | ||
SQLite doesn't have any special way to bulk insert data. To get optimal performance when inserting or updating data, ensure that you do the following: | ||
|
||
mairaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. Use a transaction. | ||
2. Reuse the same parameterized command. Subsequent executions will reuse the compilation of the first one. | ||
- Use a transaction. | ||
- Reuse the same parameterized command. Subsequent executions will reuse the compilation of the first one. | ||
|
||
[!code-csharp[](../../../../samples/snippets/standard/data/sqlite/BulkInsertSample/Program.cs?name=snippet_BulkInsert)] |
Uh oh!
There was an error while loading. Please reload this page.