Python Datacklasse und SQLite3 -AdapterPython

Python-Programme
Anonymous
 Python Datacklasse und SQLite3 -Adapter

Post by Anonymous »

Wie ist die sauberste Methode, um Daten zu bestimmen, die in Instanzen einer DataClass gespeichert sind, die in einer Liste zu SQLite mit SQLite3 's Executemany ?

Code: Select all

@dataclass
class Person:
name: str
age: int

a = Person("Alice", 21)
b = Person("Bob", 22)
c = Person("Charlie", 23)

people = [a, b, c]

# ...

cursor.executemany(f"INSERT INTO {table} ({headers}) ({placeholders})", people) #

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Sqlite3, Python und Anaconda auf Redhat 7.9
    by Anonymous » » in Python
    0 Replies
    16 Views
    Last post by Anonymous
  • Sqlite3, Python und Anaconda auf Redhat 7.9
    by Anonymous » » in Linux
    0 Replies
    21 Views
    Last post by Anonymous
  • SQLite3 und Python auf Redhat 7.9 [geschlossen]
    by Anonymous » » in Python
    0 Replies
    17 Views
    Last post by Anonymous
  • SQLite3 und Python auf Redhat 7.9 [geschlossen]
    by Anonymous » » in Linux
    0 Replies
    10 Views
    Last post by Anonymous
  • SQLite3 und Python auf Redhat 7.9 [geschlossen]
    by Anonymous » » in Linux
    0 Replies
    20 Views
    Last post by Anonymous