pysec icon indicating copy to clipboard operation
pysec copied to clipboard

PySEC with Django & Sqlite3

Open balexbyrd opened this issue 11 years ago • 4 comments

I'm having issues implementing this with Django and Sqlite3. Your Read Me stipulates change the DATA_DIR in the settings.py module but there is no DATA_DIR to change unless copy and pasted into settings. Is this what we're supposed to do? I also didn't understand the "Put this Django app under manage.py". What exactly do you mean?

Ultimately I'm trying to get the sec_import_index and sec_xbrl_to_csv to work. Maybe a step by step to getting those to work with Django & Sqlite3 will help others. Thanks in advance for any help.

balexbyrd avatar Jan 27 '14 00:01 balexbyrd

Try this. Go to the base pysec folder and ~~make an empty database, and~~ rename local-settings-example.py to local-settings.py:

$ cd ~/path/to/pysec && python -c "import sqlite3; sqlite3.connect('edgar.db')"
$ mv ./local-settings-example.py ./local-settings.py
$ mkdir ./pysec/data

Then change these settings in local-settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'edgar.db' 
        ### Django automatically creates a db
        ### Rest not needed
    }
}

SECRET_KEY = 'eddiebravo'
DATA_DIR = "%s/pysec/data" % PROJECT_ROOT

Then rerun:

$ python manage.py syncdb
$ python manage.py sec_import_index

This should populate the database with entries from a zipped SEC index file. Open up an interactive session and test out the commands in example.py with:

$ python manage.py shell
from pysec.models import *
filing = Index.objects.filter(form='10-K',cik=1057758).order_by('-date')[0]
x = filing.xbrl()
x.fields

peitalin avatar Jan 30 '14 15:01 peitalin

this doesn't seem to be helping.. i am still getting the error Unknown command: 'syncdb' Type 'manage.py help' for usage.

kumarivin avatar May 11 '17 15:05 kumarivin

You've probably figured this out, but for anyone else who finds this: syncdb was deprecated in django. Now the command is python manage.py migrate

dashstander avatar Aug 14 '17 23:08 dashstander

could someone help me understand how to use this package?

joeymizrahi avatar Oct 26 '18 13:10 joeymizrahi