kapilratnani / django_hana Goto Github PK
View Code? Open in Web Editor NEW[Discontinued] Django db backend for SAP HANA
License: BSD 3-Clause "New" or "Revised" License
[Discontinued] Django db backend for SAP HANA
License: BSD 3-Clause "New" or "Revised" License
Transaction do not roll back when issuing a save or update when using the django decorator @transaction.commit_manually(using="db") pretty sure it jus stays in auto commit mode.
Is there an ability to create a table with history/timetravel like in this example.
I've configured the settings.py as indicated and it looks like it's not recognizing the engine. I've tried also with django.db.backends.django_hana with the same results. Any hints?
'data_source': {
'ENGINE':'django_hana',
'NAME': 'IOT',
'USER': 'ALEX',
'PASSWORD': 'PASSWORD',
'HOST': '186.47.255.17',
'PORT': '30015',
}
I'm getting the error:
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x7f296919b320>
Traceback (most recent call last):
File "/home/django/Env/product/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(_args, *_kwargs)
File "/home/django/Env/product/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/home/django/Env/product/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/home/django/Env/product/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/django/Env/product/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/home/django/Env/product/lib/python2.7/site-packages/django/db/models/base.py", line 1172, in check
errors.extend(cls._check_long_column_names())
File "/home/django/Env/product/lib/python2.7/site-packages/django/db/models/base.py", line 1587, in _check_long_column_names
connection = connections[db]
File "/home/django/Env/product/lib/python2.7/site-packages/django/db/utils.py", line 212, in getitem
backend = load_backend(db['ENGINE'])
File "/home/django/Env/product/lib/python2.7/site-packages/django/db/utils.py", line 135, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django_hana' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: cannot import name BaseDatabaseOperations
^C(product) django@ip-172-31-63-203:/product>/product> python
(product) django@ip-172-31-63-203:
Python 2.7.9 (default, Dec 13 2014, 18:02:08) [GCC] on linux2
.
The problem is that in newer vesions of Django ModelForms fail to work with 0/1 as the BooleanField values. The admin, for example, always renders enabled checkboxes for BooleanFields, even when the value is 0.
Other backends have shown the same problems, see https://code.djangoproject.com/ticket/15169
The fix is to convert 0/1 to True/False in the backend. I ported the gis.mysql fix to Hana, pull request incoming.
Environment:
Request Method: POST
Request URL: http://10.48.171.221:8000/admin/
Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django_extensions',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli',
'django.contrib.admin',
'haystack',
'webapp')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
response = callback(request, _callback_args, *_callback_kwargs)
return self.admin_view(view, cacheable)(_args, *_kwargs)
response = view_func(request, _args, *_kwargs)
response = view_func(request, _args, *_kwargs)
if not self.has_permission(request):
return request.user.is_active and request.user.is_staff
self._setup()
self._wrapped = self._setupfunc()
request.user = SimpleLazyObject(lambda: get_user(request))
request._cached_user = auth.get_user(request)
user_id = request.session[SESSION_KEY]
return self._session[key]
self._session_cache = self.load()
expire_date__gt=timezone.now()
return self.get_query_set().get(_args, *_kwargs)
num = len(clone)
self._result_cache = list(self.iterator())
for row in compiler.results_iter():
for rows in self.execute_sql(MULTI):
cursor.execute(sql, params)
return CursorWrapper.execute(self,sql, params)
self.cursor.execute(self._replace_params(sql,len(params) if params else 0),params)
ret = self.__execute(operation, parameters)
ret = self.__cursor.execute(operation, parameters=parameters, iscall=iscall)
Exception Type: Error at /admin/
Exception Value: (-10413, 'Illegal TIMESTAMP value for parameter/column (2)')
Hi there, we were on another computer and we were trying to sync to a remote amazon ec2 DB but it seems that the syncdb script tries to create the tables even if they exist. Is this something we are missing here?
ubuntu:/sc/StudentCloud$ sudo python manage.py syncdb -v 3
Creating tables ...
Processing auth.Permission model
Creating table auth_permission
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/init.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/dist-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(_args, *_options)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 102, in handle_noargs
cursor.execute(statement)
File "/usr/local/lib/python2.7/dist-packages/django_hana/base.py", line 95, in execute
return CursorWrapper.execute(self,sql, params)
File "/usr/local/lib/python2.7/dist-packages/django_hana/base.py", line 75, in execute
self.cursor.execute(self._replace_params(sql,len(params) if params else 0),params)
File "/usr/lib/python2.7/dist-packages/hdbcli/dbapi.py", line 363, in execute
ret = self.__execute(operation, parameters)
File "/usr/lib/python2.7/dist-packages/hdbcli/dbapi.py", line 244, in __execute
ret = self.__cursor.execute(operation, parameters=parameters, iscall=iscall)
hdbcli.dbapi.Error: (288, 'cannot use duplicate table name: AUTH_PERMISSION: line 1 col 18 (at pos 17)')
Running ./manage.py dbshell gives "Error: You appear not to have the 'hdbsql' program installed or on your path." So I am not sure of a good way to alter tables.
Is it possible when adding the foreignkey value to the django model that it would actually create the foreignkey in the sql. I know that hana recently added support for foreign keys.
http://scn.sap.com/community/hana-in-memory/blog/2012/12/04/checking-out-foreign-keys-in-hana-sps5
Environment:
Request Method: GET
Request URL: http://10.48.171.221:8000/question
Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django_extensions',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli',
'django.contrib.admin',
'haystack',
'webapp')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
response = callback(request, _callback_args, *_callback_kwargs)
return the_func(_args, *_kwargs)
response = view_func(request, _args, *_kwargs)
return self.read_all(request)
'related_tags' : [t.as_dict() for t in related_tags],
query = iter(self.query)
self._execute_query()
self.cursor.execute(self.sql, self.params)
return CursorWrapper.execute(self,sql, params)
self.cursor.execute(self._replace_params(sql,len(params) if params else 0),params)
ret = self.__execute(operation, parameters)
ret = self.__cursor.execute(operation, parameters=parameters, iscall=iscall)
Exception Type: Error at /question
Exception Value: (277, 'not a GROUP BY expression: T.*: line 2 col 24 (at pos 24)')
Running a distinct query does not work if I run the following django it will produce the following sql
Django:
OrgBuilder.objects.order_by('Eff_Date').distinct('Eff_Date')
The sql will produce:
SELECT DISTINCT (OrgBuilder_orgbuilder.Eff_Date) OrgBuilder_orgbuilder.id, OrgBuilder_orgbuilder.Eff_Date, OrgBuilder_orgbuilder.instID, OrgBuilder_orgbuilder.Valid_From, OrgBuilder_orgbuilder.Valid_To, OrgBuilder_orgbuilder.Enable, OrgBuilder_orgbuilder.UserID_id FROM OrgBuilder_orgbuilder ORDER BY OrgBuilder_orgbuilder.Eff_Date ASC
that generates the following error:
Error: (257, 'sql syntax error: incorrect syntax near ".": line 1 col 50 (at pos 50)')
The sql it should produces should be like the following:
SELECT DISTINCT OrgBuilder_orgbuilder.Eff_Date FROM studentcloud_developer.OrgBuilder_orgbuilder ORDER BY OrgBuilder_orgbuilder.Eff_Date ASC
Institution.objects.using(db(request)).filter(Description_Short__icontains= "Short")
The following query below creates a sql similar to above
SELECT FoundationBuilder_institution.id, FoundationBuilder_institution.InstID, FoundationBuilder_institution.UserID, FoundationBuilder_institution.Eff_Date, FoundationBuilder_institution.Address, FoundationBuilder_institution.Description_Short, FoundationBuilder_institution.Description_Long, FoundationBuilder_institution.Phone_Number, FoundationBuilder_institution.Fax_Number, FoundationBuilder_institution.Audit, FoundationBuilder_institution.Created FROM FoundationBuilder_institution WHERE FoundationBuilder_institution.Description_Short LIKE UPPER(%Short%) LIMIT 21
However, the type of query it should create should have the column wrapped in upper also like so. If not the query wont return anything
SELECT * FROM "STUDENTCLOUD"."FOUNDATIONBUILDER_INSTITUTION"
WHERE UPPER(Description_Short) LIKE UPPER('%short%') LIMIT 21
"Attempting to post a new question and encountered this error... the info did get posted to the table"
Environment:
Request Method: GET
Request URL: http://10.48.171.221:8000/question/1/first-question
Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django_extensions',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli',
'django.contrib.admin',
'haystack',
'webapp')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
response = callback(request, _callback_args, *_callback_kwargs)
return the_func(_args, *_kwargs)
response = view_func(request, _args, *_kwargs)
return self.read(request, id)
for q in rel_questions:
query = iter(self.query)
self._execute_query()
self.cursor.execute(self.sql, self.params)
return CursorWrapper.execute(self,sql, params)
self.cursor.execute(self._replace_params(sql,len(params) if params else 0),params)
ret = self.__execute(operation, tuple(parameters))
ret = self.__cursor.execute(operation, parameters=parameters, iscall=iscall)
Exception Type: Error at /question/1/first-question
Exception Value: (257, 'sql syntax error: incorrect syntax near ",": line 12 col 15 (at pos 457)')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.