Comments (6)
I tried to run raw sql against db, using:
# In router.py
class DatabaseRouter(object):
def db_for_read(self, model, **hints):
return 'legacy' if model._meta.app_label == 'legacy' else 'default'
def db_for_write(self, model, **hints):
return 'legacy' if model._meta.app_label == 'legacy' else 'default'
def allow_relation(self, obj1, obj2, **hints):
return None
def allow_migrate(self, db, model):
return None
# In settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '...',
'USER': '...',
'PASSWORD': '...',
'HOST': '...',
'PORT': '...'
},
'legacy': {
'ENGINE': 'firebird',
'NAME': '...',
'USER': 'SYSDBA',
'PASSWORD': 'masterkey',
'HOST': 'localhost',
'PORT': '3050',
# 'OPTIONS': {'charset': 'ISO8859_1'},
}
}
DATABASE_ROUTERS = ['...router.DatabaseRouter',]
>>> from django.db import connections
>>> c = connections['legacy'].cursor() # <= 'legacy' is the firebird db in settings.DATABASES
>>> c.execute('select 1')
/usr/local/lib/python2.7/dist-packages/django/db/backends/util.pyc in execute(self, sql, params)
67 start = time()
68 try:
---> 69 return super(CursorDebugWrapper, self).execute(sql, params)
70 finally:
71 stop = time()
/usr/local/lib/python2.7/dist-packages/django/db/backends/util.pyc in execute(self, sql, params)
51 return self.cursor.execute(sql)
52 else:
---> 53 return self.cursor.execute(sql, params)
54
55 def executemany(self, sql, param_list):
/usr/local/lib/python2.7/dist-packages/django/db/utils.pyc in __exit__(self, exc_type, exc_value, traceback)
84 Error,
85 ):
---> 86 db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
87 if issubclass(exc_type, db_exc_type):
88 # Under Python 2.6, exc_value can still be a string.
AttributeError: 'DatabaseWrapper' object has no attribute 'Database'
from django-firebird.
This issue is affecting the Django==1.6.
With 1.5 I've got string encoding error when settings not define CHARSET
and strange characters when it is defined.
from django-firebird.
Hi geovanisouza92,
Are you using django 1.6 with the django-firebird repository version?
Please, check if you are using the last version from master branch.
Related to CHARSET issue, if you don't define the charset option django-firebird will use the default UTF8
from django-firebird.
@maxirobaina With latest version applied, I've got:
>>> Equipment.objects.count()
/usr/local/lib/python2.7/dist-packages/django/db/models/manager.pyc in count(self)
134
135 def count(self):
--> 136 return self.get_queryset().count()
137
138 def dates(self, *args, **kwargs):
/usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in count(self)
289 return len(self._result_cache)
290
--> 291 return self.query.get_count(using=self.db)
292
293 def get(self, *args, **kwargs):
/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.pyc in get_count(self, using)
388
389 obj.add_count_column()
--> 390 number = obj.get_aggregation(using=using)[None]
391
392 # Apply offset and limit constraints manually, since using LIMIT/OFFSET
/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.pyc in get_aggregation(self, using)
354 query.related_select_cols = []
355
--> 356 result = query.get_compiler(using).execute_sql(SINGLE)
357 if result is None:
358 result = [None for q in query.aggregate_select.items()]
/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.pyc in execute_sql(self, result_type)
779 return
780
--> 781 cursor = self.connection.cursor()
782 cursor.execute(sql, params)
783
/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.pyc in cursor(self)
155 if (self.use_debug_cursor or
156 (self.use_debug_cursor is None and settings.DEBUG)):
--> 157 cursor = self.make_debug_cursor(self._cursor())
158 else:
159 cursor = util.CursorWrapper(self._cursor(), self)
/usr/local/lib/python2.7/dist-packages/firebird/base.pyc in _cursor(self)
112 self._db_charset = conn_params.get('charset')
113 self.encoding = charset_map.get(self._db_charset, 'utf_8')
--> 114 self.connection = Database.connect(**conn_params)
115 connection_created.send(sender=self.__class__)
116
/usr/local/lib/python2.7/dist-packages/fdb/fbcore.pyc in connect(dsn, user, password, host, port, database, sql_dialect, role, charset, buffers, force_write, no_reserve, db_key_scope, isolation_level, connection_class)
643 con = fdb.connect(host='myhost', database='/path/database.fdb', user='sysdba', password='pass', charset='UTF8')
644 """
--> 645 load_api()
646 if connection_class == None:
647 connection_class = Connection
/usr/local/lib/python2.7/dist-packages/fdb/fbcore.pyc in load_api()
174 def load_api():
175 if not api:
--> 176 setattr(sys.modules[__name__],'api',fbclient_API())
177 return api
178
/usr/local/lib/python2.7/dist-packages/fdb/ibase.pyc in __init__(self)
1153 def __init__(self):
1154
-> 1155 self.isc_attach_database = fb_library.isc_attach_database
1156 self.isc_attach_database.restype = ISC_STATUS
1157 self.isc_attach_database.argtypes = [POINTER(ISC_STATUS), c_short, STRING,
/usr/lib/python2.7/ctypes/__init__.pyc in __getattr__(self, name)
376 if name.startswith('__') and name.endswith('__'):
377 raise AttributeError(name)
--> 378 func = self.__getitem__(name)
379 setattr(self, name, func)
380 return func
/usr/lib/python2.7/ctypes/__init__.pyc in __getitem__(self, name_or_ordinal)
381
382 def __getitem__(self, name_or_ordinal):
--> 383 func = self._FuncPtr((name_or_ordinal, self))
384 if not isinstance(name_or_ordinal, (int, long)):
385 func.__name__ = name_or_ordinal
AttributeError: python: undefined symbol: isc_attach_database
With no changes in firebird instalation. Just Django==1.6
from django-firebird.
Ok, next round. I found the issue. Is one incompatibility with http://github.com/simone/django-compositekey. Even if I query a model with no composite key, the error appears. If a comment out the MultiFieldPK
all works well, except for Django==1.6.
Apparently isc_attach_database
function was not found.
from django-firebird.
@maxirobaina Finally done! :D
I've forget to install libfbclient2
and reinstalled a lot the packages. With new vagrant VM, all clear, installed and tested everything and all work.
Now, I have my integration app working with composite keys (two fields for primary key), legacy db and celery tasks.
Thank you a lot for project and patience. Have a nice day!
from django-firebird.
Related Issues (20)
- Django 3 support HOT 11
- Support firebird dialect 1. HOT 1
- TypeError at operations.convert_decimalfield_value HOT 2
- BinaryField() does not save like stream HOT 2
- add support for firebird 3 / python 3 driver HOT 1
- Does the lib work on windows? HOT 1
- Error al conectar firebird + django 3.2.6.0 HOT 7
- Django 3.2 and firebird 3 error connection HOT 1
- 'float' object has no attribute 'quantize' HOT 1
- Django 4 and Firebird 4 support HOT 1
- Time to rename django-firebird python package HOT 2
- Error on django3 with BOOL fields HOT 1
- KeyError: 'deferrable' HOT 2
- CREATE PROCEDURE DJANGO_SITE_RS failed
- TypeError: convert_booleanfield_value() missing 1 required positional argument: 'context'
- django migration already exists
- Column unknown tablename.RDB$DB_KEY
- Time for a name change? HOT 1
- virtualenv can't be populated from requirements.txt, asgiref version conflict, upath just won't build (python 3.12, Ubuntu 23.10)
- Tests don't run
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-firebird.