Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
python:firebird:start [2021/04/22 04:55] marclebrun |
python:firebird:start [2021/06/14 06:58] (Version actuelle) marclebrun |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Firebird ====== | ====== Firebird ====== | ||
- | |||
- | * [[https://firebird-driver.readthedocs.io/en/latest/|The Python driver for Firebird]] | ||
- | |||
- | ===== Installation ===== | ||
- | |||
- | <code bash> | ||
- | pip install firebird-driver | ||
- | </code> | ||
- | |||
- | ===== Connexion et requête simple ===== | ||
- | |||
- | <code python> | ||
- | from firebird.driver import connect, driver_config | ||
- | |||
- | srv_cfg = """[mon_serveur] | ||
- | host = 192.168.1.1 | ||
- | user = SYSDBA | ||
- | password = masterkey | ||
- | """ | ||
- | |||
- | db_cfg = """[facturation] | ||
- | server = mon_serveur | ||
- | database = c:\\databases\\facturation.fdb | ||
- | protocol = inet | ||
- | charset = ISO8859_1 | ||
- | """ | ||
- | |||
- | driver_config.register_server('mon_serveur', srv_cfg) | ||
- | driver_config.register_database('facturation', db_cfg) | ||
- | |||
- | con = connect('facturation') | ||
- | |||
- | cur = con.cursor() | ||
- | cur.execute(""" | ||
- | select id, nom, adresse | ||
- | from clients | ||
- | where nom containing 'marc'; | ||
- | """) | ||
- | |||
- | print(cur.fetchall()) | ||
- | </code> | ||