tech:notes_odbc
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| tech:notes_odbc [2025/11/11 17:34] – Jean-Baptiste | tech:notes_odbc [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag>DB Python}} | ||
| + | |||
| + | # Notes ODBC | ||
| + | |||
| + | Voir : | ||
| + | * odbc_avec_freetds [[connexion_a_une_base_proprietaire_-_python_-_jdbc_-_odbc|Exemple d'ODBC avec microsoft SQL Server]] | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * DB API 2.0 | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | apt-get install unixodbc odbcinst | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | apt-get install odbc-postgresql libsqliteodbc libmyodbc | ||
| + | ~~~ | ||
| + | |||
| + | Sur Debian à ne pas éditer directement, | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [SQLite] | ||
| + | Description=SQLite ODBC Driver | ||
| + | Driver=/ | ||
| + | Setup=/ | ||
| + | UsageCount=1 | ||
| + | |||
| + | [SQLite3] | ||
| + | Description=SQLite3 ODBC Driver | ||
| + | Driver=/ | ||
| + | Setup=/ | ||
| + | UsageCount=1 | ||
| + | |||
| + | [MySQL] | ||
| + | Description = ODBC Driver for MySQL | ||
| + | Driver = libmyodbc.so | ||
| + | Setup = libodbcmyS.so | ||
| + | FileUsage = 1 | ||
| + | CPTimeout = | ||
| + | CPReuse = | ||
| + | |||
| + | [PostgreSQL ANSI] | ||
| + | Description = PostgreSQL ODBC driver (ANSI version) | ||
| + | Driver = psqlodbca.so | ||
| + | Setup = libodbcpsqlS.so | ||
| + | Debug = 0 | ||
| + | CommLog = 1 | ||
| + | UsageCount = 2 | ||
| + | |||
| + | [PostgreSQL Unicode] | ||
| + | Description = PostgreSQL ODBC driver (Unicode version) | ||
| + | Driver = psqlodbcw.so | ||
| + | Setup = libodbcpsqlS.so | ||
| + | Debug = 0 | ||
| + | CommLog = 1 | ||
| + | UsageCount = 2 | ||
| + | ~~~ | ||
| + | |||
| + | `~/ | ||
| + | ~~~ini | ||
| + | [mydb1] | ||
| + | Description | ||
| + | Driver | ||
| + | Server | ||
| + | Database | ||
| + | Port = 3306 | ||
| + | Socket | ||
| + | Option | ||
| + | Stmt = | ||
| + | |||
| + | [mydb2] | ||
| + | Description | ||
| + | Driver | ||
| + | Server | ||
| + | Database | ||
| + | Port = 3306 | ||
| + | Socket | ||
| + | Option | ||
| + | Stmt = | ||
| + | |||
| + | [tracdb] | ||
| + | Description=SQLite3 Trac | ||
| + | Driver=SQLite3 | ||
| + | Database=/ | ||
| + | # optional lock timeout in milliseconds | ||
| + | # | ||
| + | ~~~ | ||
| + | |||
| + | Vérifier la connexion avec iusql | ||
| + | ~~~bash | ||
| + | iusql tracdb | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | iusql mydb1 root P@ssw0rd | ||
| + | ~~~ | ||
| + | |||
| + | Connaître le schéma de la base | ||
| + | |||
| + | Equivalent à `show tables` | ||
| + | ~~~bash | ||
| + | $ iusql -d, -b SQLiteODBC <<< | ||
| + | ,, | ||
| + | ~~~ | ||
| + | |||
| + | Équivalent à `describe table` | ||
| + | ~~~ | ||
| + | $ iusql -d, -b SQLiteODBC <<< | ||
| + | ,, | ||
| + | ,, | ||
| + | ,, | ||
| + | ,, | ||
| + | ,, | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Exemple en Python | ||
| + | |||
| + | ~~~python | ||
| + | import sqlalchemy | ||
| + | from sqlalchemy.exc import | ||
| + | |||
| + | engine = sqlalchemy.create_engine(' | ||
| + | |||
| + | try: | ||
| + | engine.connect() | ||
| + | except DBAPIError: | ||
| + | pass | ||
| + | |||
| + | for row in engine.execute(' | ||
| + | print (row) | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | ~~~ | ||
| + | odbcinst -j | ||
| + | unixODBC 2.3.11 | ||
| + | DRIVERS............: | ||
| + | SYSTEM DATA SOURCES: / | ||
| + | FILE DATA SOURCES..: / | ||
| + | USER DATA SOURCES..: / | ||
| + | SQLULEN Size.......: | ||
| + | SQLLEN Size........: | ||
| + | SQLSETPOSIROW Size.: 8 | ||
| + | ~~~ | ||
| + | |||
| + | |||
