| 1 |
import warnings |
|---|
| 2 |
|
|---|
| 3 |
from geniusql.providers import ado, sqlserver, msaccess |
|---|
| 4 |
from dejavu import errors |
|---|
| 5 |
from dejavu.storage import db |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
class StorageManagerADO_SQLServer(db.StorageManagerDB): |
|---|
| 9 |
"""StoreManager to save and retrieve Units via ADO 2.7. |
|---|
| 10 |
|
|---|
| 11 |
You must run makepy on ADO 2.7 before installing. |
|---|
| 12 |
""" |
|---|
| 13 |
|
|---|
| 14 |
databaseclass = sqlserver.SQLServerDatabase |
|---|
| 15 |
|
|---|
| 16 |
def __init__(self, allOptions={}): |
|---|
| 17 |
atoms = ado.connatoms(allOptions['connections.Connect']) |
|---|
| 18 |
allOptions['name'] = atoms.get('INITIAL CATALOG') or atoms.get('DSN') |
|---|
| 19 |
db.StorageManagerDB.__init__(self, allOptions) |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
class StorageManagerADO_MSAccess(db.StorageManagerDB): |
|---|
| 23 |
"""StoreManager to save and retrieve Units via ADO 2.7. |
|---|
| 24 |
|
|---|
| 25 |
You must run makepy on ADO 2.7 before installing. |
|---|
| 26 |
""" |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
databaseclass = msaccess.MSAccessDatabase |
|---|
| 30 |
|
|---|
| 31 |
def __init__(self, allOptions={}): |
|---|
| 32 |
atoms = ado.connatoms(allOptions['connections.Connect']) |
|---|
| 33 |
allOptions['name'] = (atoms.get('DATA SOURCE') or |
|---|
| 34 |
atoms.get('DATA SOURCE NAME') or |
|---|
| 35 |
atoms.get('DBQ')) |
|---|
| 36 |
db.StorageManagerDB.__init__(self, allOptions) |
|---|
| 37 |
|
|---|
| 38 |
def _make_column(self, cls, key): |
|---|
| 39 |
col = db.StorageManagerDB._make_column(self, cls, key) |
|---|
| 40 |
if col.dbtype == "MEMO": |
|---|
| 41 |
for assoc in cls._associations.itervalues(): |
|---|
| 42 |
if assoc.nearKey == key: |
|---|
| 43 |
warnings.warn("Memo fields cannot be used as join keys. " |
|---|
| 44 |
"You should set %s.%s(hints={'bytes': 255})" |
|---|
| 45 |
% (cls.__name__, key), errors.StorageWarning) |
|---|
| 46 |
return col |
|---|
| 47 |
|
|---|