<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using Django to read SQLite DB in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Using-Django-to-read-SQLite-DB/m-p/128942#M1847</link>
    <description>&lt;P&gt;I'm trying to use Django to load some data from a small SQLite database (for testing purposes..).&lt;/P&gt;

&lt;P&gt;My Django table model is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class Coworker(models.Model):
    id = models.IntegerField(primary_key=True)
    firstname = models.CharField(max_length=50)
    lastname = models.CharField(max_length=50)

    def __unicode__(self):
        return self.firstname + " " + self.lastname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the Django view, I try getting all objects from DB with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;items = Coworker.objects.all()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My database config (in __init__.py) looks as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me the following error message:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Error: ImproperlyConfigured at /de-de/myfirstdjangoapp/coworkers/&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I then tried moving the DB settings stuff to other files:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;urls.py&lt;/LI&gt;
&lt;LI&gt;views.py&lt;/LI&gt;
&lt;LI&gt;/opt/splunk/lib/python2.7/site-packages/django/conf/global_settings.py&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;But nothing helped, always the same error.&lt;/P&gt;

&lt;P&gt;Then I added another, named, data source:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    },
    'testdb': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And tested with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;items = Coworker.objects.using("testdb").all()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, I got a new error message:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Error: ConnectionDoesNotExist at /de-de/myfirstdjangoapp/coworkers&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The connection testdb doesn't exist&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Which I find odd since I just added it.&lt;/P&gt;

&lt;P&gt;What do I have to do to get a connection to said database?&lt;/P&gt;</description>
    <pubDate>Fri, 11 Apr 2014 13:13:05 GMT</pubDate>
    <dc:creator>AndreasBalster</dc:creator>
    <dc:date>2014-04-11T13:13:05Z</dc:date>
    <item>
      <title>Using Django to read SQLite DB</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Using-Django-to-read-SQLite-DB/m-p/128942#M1847</link>
      <description>&lt;P&gt;I'm trying to use Django to load some data from a small SQLite database (for testing purposes..).&lt;/P&gt;

&lt;P&gt;My Django table model is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class Coworker(models.Model):
    id = models.IntegerField(primary_key=True)
    firstname = models.CharField(max_length=50)
    lastname = models.CharField(max_length=50)

    def __unicode__(self):
        return self.firstname + " " + self.lastname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the Django view, I try getting all objects from DB with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;items = Coworker.objects.all()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My database config (in __init__.py) looks as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me the following error message:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Error: ImproperlyConfigured at /de-de/myfirstdjangoapp/coworkers/&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I then tried moving the DB settings stuff to other files:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;urls.py&lt;/LI&gt;
&lt;LI&gt;views.py&lt;/LI&gt;
&lt;LI&gt;/opt/splunk/lib/python2.7/site-packages/django/conf/global_settings.py&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;But nothing helped, always the same error.&lt;/P&gt;

&lt;P&gt;Then I added another, named, data source:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    },
    'testdb': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/home/j299110/testdb'
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And tested with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;items = Coworker.objects.using("testdb").all()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, I got a new error message:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Error: ConnectionDoesNotExist at /de-de/myfirstdjangoapp/coworkers&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The connection testdb doesn't exist&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Which I find odd since I just added it.&lt;/P&gt;

&lt;P&gt;What do I have to do to get a connection to said database?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 13:13:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Using-Django-to-read-SQLite-DB/m-p/128942#M1847</guid>
      <dc:creator>AndreasBalster</dc:creator>
      <dc:date>2014-04-11T13:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using Django to read SQLite DB</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Using-Django-to-read-SQLite-DB/m-p/128943#M1848</link>
      <description>&lt;P&gt;This isn't supported because Splunk doesn't include the SQLite C libraries necessary to make the connection. Some people &lt;A href="http://answers.splunk.com/answers/109009/splunk6-django-app-importing-sqlite"&gt;have done it successfully&lt;/A&gt; but better methods likely exist. If you want to get data from a SQLite database, try using &lt;A href="http://apps.splunk.com/app/958/"&gt;DB Connect&lt;/A&gt; which includes the &lt;A href="http://answers.splunk.com/answers/129338/suggestion-enabling-connectivity-to-sqlite"&gt;SQLite driver&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 04:42:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Using-Django-to-read-SQLite-DB/m-p/128943#M1848</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2014-04-15T04:42:03Z</dc:date>
    </item>
  </channel>
</rss>

