How to get sysdate value from oracle DB in django -


how sysdate value oracle db using django? tried adding dual class in model below:

class dual(models.model): dummy = models.charfield(max_length=1, null=true, blank=true) sysdate = models.datefield(blank=true, null=true) class meta:     managed = false     db_table = 'dual' 

tried accessing sysdate:

sysdate = dual.objects.only('sysdate') 

but result in below error:

databaseerror: ora-00904: "dual"."sysdate": invalid identifier

am doing wrong? please me here. in advance

you can retrieve rows select statement cursor iterator. know sysdate query return 1 row, can use fetchone() method.

views.py

from django.db import connection  def get_sysdate(request):     cursor = connection.cursor()      sql = cursor.execute("select to_char(sysdate,'dd.mm.yyyy hh24:mi:ss') dual")     result = cursor.fetchone()     return render(request, 'sysdate.html', {         'result' : result,     }) 

sysdate.html

{{ result }} 

you can find related information below link. cx_oracle - fetch


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -