Writing to an SQLite3 Database in Nimrod

This is pretty straight-forward, but I didn’t see any tutorials about creating SQLite3 databases with Nimrod on the internet. I put this together after looking at this Nimrod forum string, and GitHub page referenced in that discussion.

import db_sqlite

# create a connection
var db = open( connection="my.db", user="connor", password="", database="mydb" )

# create a table
db.exec( sql"""CREATE TABLE Paths( FilePath TEXT, ModifyTime TEXT, AccessTime TEXT, CreateTime TEXT );""" )

# populate table with a row
db.exec( sql"""INSERT INTO Paths VALUES( "/Users/connorjohnson", "Sat Aug 29", "Sat Aug 29", "Sat Aug 29" );""" )

# close the connection

Leave a Reply

Your email address will not be published. Required fields are marked *