ouvert_a_tous:prepas:bdd:python:accueil

Principes de base

# Never do this -- insecure!
symbol = 'IBM'
c.execute("select * from stocks where symbol = '%s'" % symbol)
 
# Do this instead
t = ('IBM',)
c.execute('select * from stocks where symbol=?', t)
 
# Larger example
for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
          ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
          ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
         ]:
    c.execute('insert into stocks values (?,?,?,?,?)', t)
  • ouvert_a_tous/prepas/bdd/python/accueil.txt
  • Dernière modification : 2022/12/03 07:45
  • de 127.0.0.1