User Tools

Site Tools


snippets:python:db

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

snippets:python:db [2026-04-01 16:14] – created malte70snippets:python:db [2026-04-01 17:39] (current) malte70
Line 31: Line 31:
 </code> </code>
  
 +===== SQLite =====
 +
 +  * [[https://sqlite.org/|SQLite]]
 +
 +==== Beispiel ====
 +
 +<code python [enable_line_numbers="true"]>
 +import os
 +import sqlite3
 +
 +
 +DB = "~/python.sqlite3"
 +
 +
 +DB = os.path.expanduser(
 +    os.path.expandvars(DB)
 +)
 +if not os.path.exists(DB):
 +    pass
 +
 +con = sqlite3.connect(DB)
 +cur = con.cursor()
 +cur.execute("CREATE TABLE IF NOT EXISTS ...")
 +</code>
snippets/python/db.txt · Last modified: by malte70