PersistentTable
RawCommand
issue a command to the database managing a PersistentTable connection
Calling Sequence
Parameters
Description
Thread Safety
Examples
Compatibility
RawCommand(connection, command)
connection
-
PersistentTable object created with the Open command
command
string giving an SQLite command
The RawCommand command issues a command to the database managing a PersistentTable connection. This calls the Database[SQLite][Execute] command and returns what it returns.
The internal layout of PersistentTable tables is not documented, and not guaranteed to remain the same in future Maple releases. We do not recommended that you rely on this layout with your code.
The RawCommand command can be used to manage database transactions, issuing the command RawCommand("BEGIN TRANSACTION") to start a transaction and RawCommand("COMMIT TRANSACTION") to commit it or RawCommand("ROLLBACK TRANSACTION") to roll it back. In a PersistentTable (or any SQLite database), by default, each change to the database is a separate transaction. If you make many changes to a SQLite database, you generally get much better performance if you put them in a single transaction rather than in many individual transactions. Moreover, if you are able to group logically connected changes together in a transaction, then if something goes wrong (such as a power failure, or if your Maple session crashes, for example), the connected changes will either all be written to the database, or none of them will. This can help ensure that the database is in a consistent state upon restart.
For more information about SQLite commands, see the SQLite language documentation.
Persistent tables are in general thread safe as of Maple 2021; see the Thread Safety section of the PersistentTable overview page for more details and caveats.
For more information on thread safety, see index/threadsafe.
with⁡PersistentTable
Close,Count,Get,GetAll,GetKeys,Has,MaybeGet,Open,RawCommand,Set
store≔Open⁡:memory:,style=k::integer,v::anything
store≔<< 2-column persistent table at :memory: >>
These values are stored before the start of the transaction.
store5≔v⁡5
store4≔v⁡4
GetAll⁡store
4,v⁡4,5,v⁡5
RawCommand⁡store,BEGIN TRANSACTION
store3≔v⁡3
store7≔v⁡7
store5≔v⁡6
3,v⁡3,4,v⁡4,5,v⁡6,7,v⁡7
Now we abort the transaction. The changes since the start of the transaction are rolled back.
RawCommand⁡store,ROLLBACK TRANSACTION
Close⁡store
The PersistentTable[RawCommand] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
PersistentTable[Open]
Download Help Document