source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/gluon/packages/dal/tests/_adapt.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 954 bytes
Line 
1import os
2
3DEFAULT_URI = os.getenv("DB", "sqlite:memory")
4IS_IMAP = "imap" in DEFAULT_URI
5IS_GAE = "datastore" in DEFAULT_URI
6IS_MONGODB = "mongodb" in DEFAULT_URI
7IS_POSTGRESQL = "postgres" in DEFAULT_URI
8IS_SQLITE = "sqlite" in DEFAULT_URI
9IS_MSSQL = "mssql" in DEFAULT_URI
10IS_MYSQL = "mysql" in DEFAULT_URI
11IS_TERADATA = "teradata" in DEFAULT_URI
12IS_ORACLE = "oracle" in DEFAULT_URI
13IS_NOSQL = IS_GAE or IS_MONGODB or IS_IMAP
14
15
16def drop(table, cascade=None):
17    if IS_NOSQL and not IS_MONGODB:
18        # GAE drop/cleanup is not implemented
19        db = table._db
20        db[table]._common_filter = None
21        db(table).delete()
22        del db[table._tablename]
23        del db.tables[db.tables.index(table._tablename)]
24        db._remove_references_to(table)
25    else:
26        if cascade:
27            table.drop(cascade)
28        else:
29            table.drop()
30
31
32def _quote(db, value):
33    return db._adapter.dialect.__class__.quote_template % value
Note: See TracBrowser for help on using the repository browser.