
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
sqlite3-create-and-check-table
Advanced tools
Create an SQLite table if missing or check that the existing table matches the given creation statement.
A Python package that provides a simple utility function for creating SQLite tables. The function will compare an existing table's SQL statement from the sqlite_master
table to the one expected for a given SQL table creation statement. If the existing table does not match the expected SQL statement then it can either be dropped an recreated, or a ValueError
can be raised.
The primary purpose of this function is to facilitate the creation of tables for caching temporary data that can be discarded, such as memoizing calls to remote server APIs.
import sqlite3
from sqlite3_create_and_check_table import create_and_check_table
sql = "CREATE TABLE test (prim TEXT PRIMARY KEY, int INTEGER, blob BLOB NON NULL)"
conn = sqlite3.connect("/path/to/some/sqlite3/db.sqlite")
with conn as cur:
# Create the table with the given SQL statement. If a table with the same
# name exists but differs from what would result from the given SQL table
# creation statement, it will be dropped and recreated to match the given
# statement.
# If drop is set to False then a ValueError will be raised instead.
create_and_check_table(cur, sql, drop=True)
The package also provides a row factory function for returning rows in the table as dict
s as well as an sqlite3 cursor context manager for temporarily setting the the row factory to the provided dict
factory:
import sqlite3
from sqlite3_create_and_check_table import dict_factory, dict_factory_cursor
conn = sqlite3.connect("/path/to/some/sqlite3/db.sqlite")
# Set the row factory within a context and restore the previous row factory when
# leaving the context.
with dict_factory_cursor(conn) as cur:
# cur.execute(...)
# Set the row factory for all queries.
conn.row_factory = dict_factory
FAQs
Create an SQLite table if missing or check that the existing table matches the given creation statement.
We found that sqlite3-create-and-check-table demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.