Called once by SQLAlchemy for each new SQLite DB-API connection. Here is where we issue some PRAGMA statements to configure how we're going to access the SQLite database. @param dbapi_connection: A newly connected raw SQLite DB-API connection.
(dbapi_connection, connection_record)
| 106 | """ |
| 107 | |
| 108 | def connect(dbapi_connection, connection_record): |
| 109 | """ |
| 110 | Called once by SQLAlchemy for each new SQLite DB-API connection. |
| 111 | |
| 112 | Here is where we issue some PRAGMA statements to configure how we're |
| 113 | going to access the SQLite database. |
| 114 | |
| 115 | @param dbapi_connection: |
| 116 | A newly connected raw SQLite DB-API connection. |
| 117 | |
| 118 | @param connection_record: |
| 119 | Unused by this method. |
| 120 | """ |
| 121 | try: |
| 122 | cursor = dbapi_connection.cursor() |
| 123 | try: |
| 124 | cursor.execute("PRAGMA foreign_keys = ON;") |
| 125 | cursor.execute("PRAGMA foreign_keys;") |
| 126 | if cursor.fetchone()[0] != 1: |
| 127 | raise Exception() |
| 128 | finally: |
| 129 | cursor.close() |
| 130 | except Exception: |
| 131 | dbapi_connection.close() |
| 132 | raise sqlite3.Error() |
| 133 | |
| 134 | |
| 135 | # ------------------------------------------------------------------------------ |
no test coverage detected