Compare commits

...
2 Commits
Author SHA1 Message Date
Antonio SJ Musumeci 3ac5b23fe7 checkpoint 2025-07-08 00:15:50 -05:00
Antonio SJ Musumeci 7d9796b592 checkpoint 2025-07-07 22:40:29 -05:00
2 changed files with 54 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import os
import sys
import tempfile
import mmap
import resource
(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.ftruncate(fd,resource.getpagesize())
data = mmap.mmap(fileno=fd,
length=resource.getpagesize(),
flags=mmap.MAP_PRIVATE)
data = mmap.mmap(fileno=fd,
length=resource.getpagesize(),
flags=mmap.MAP_SHARED)
os.unlink(filepath)
os.close(fd)
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import os
import sys
import sqlite3
filepath = sys.argv[1] + "test.db"
conn = sqlite3.connect(filepath, isolation_level=None)
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA mmap_size=268435456')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
age INTEGER
)
''')
cursor.execute("INSERT INTO users (name, age) VALUES (?, ?)", ("Alice", 25))
cursor.execute("INSERT INTO users (name, age) VALUES (?, ?)", ("Bob", 30))
conn.commit()
cursor.execute("SELECT * FROM users")
results = cursor.fetchall()
for row in results:
print(f"ID: {row[0]}, Name: {row[1]}, Age: {row[2]}")
conn.close()