When you want to do a SQL
UPDATE using the Flutter sqflite package, I’ve found that it’s best to use their
update methods (as shown below) so you don’t have to worry about escaping single- and double-quotes. This is similar to the reason why Java developers switched from Statement to PreparedStatement way back in the late 1900s.
As an example, given this SQLite database table:
The Scala List class as an immutable, linear, linked-list class. It’s very efficient when it makes sense for your algorithms to (a) prepend all new elements, (b) work with it in terms of its head and tail elements, and (c) use functional methods that traverse the list from beginning to end, such as
Important note about Seq, IndexedSeq, and LinearSeq
As an important note, I use
Seq in the following examples to keep things simple, but in your code you should be more precise and use
LinearSeq where appropriate. As the
Seq class Scaladoc states:
If you ever need to batch-insert a lot of records into a MySQL/MariaDB database using the JDBC
PreparedStatement (as in
preparedStatement.executeBatch()) be sure to change the MySQL URL to use the
rewriteBatchedStatements, as shown here:
For a recent project I needed to batch-insert about eleven million records into a MySQL database, and the runtime was about 55 minutes. Once I added
rewriteBatchedStatements=true to the MySQL URL, the batch-insert time was reduced down to only three minutes. That one little change made all the difference.
In general the online Play Framework documentation is excellent, but one area where I needed more help was in seeing more examples of the Anorm syntax. To that end, here are some Anorm query examples, taken from a Play Framework application I worked on recently. But first, a little background about Anorm.
I don’t remember exactly why I wrote this Scala shell script, but if I remember right I was having a problem getting
sed to work properly, so I wrote this little script to insert an Amazon Kindle “break” tag before each
<h1> tag in an HTML file: