django.db.connection - python examples

Here are the examples of the python api django.db.connection taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 View Complete Implementation : models.py
Copyright GNU General Public License v3.0
Author : CalthorpeAnalytics
    @property
    def tilestache_config_object(self):
        """
        returns a config object built by TileStache
        """
        logger.debug("building configuration object")
        connection = django.db.connection

        config = PGConfiguration(connection, '/tmp/stache', 'INFO')

        return config

0 View Complete Implementation : edgar.py
Copyright MIT License
Author : LexPredict
def export_filing_docameent_search(search_query_id: int, output_file_path: str):
    """
    Export a filing docameent search to a CSV file.
    :param search_query_id:
    :param output_file_path:
    :return:
    """
    # Local imports
    import django.db
    import pandas

    # Create query string
    query_string = """SELECT f.accession_number, f.date_filed, f.company_id, ci.name, ci.sic, ci.state_location, 
f.form_type, fd.sequence, fd.description, fd.sha1, sqt.term, sqr.count
FROM sec_edgar_searchqueryresult sqr
JOIN sec_edgar_searchqueryterm sqt ON sqt.id = sqr.term_id
JOIN sec_edgar_filingdocameent fd ON fd.id = sqr.filing_docameent_id
JOIN sec_edgar_filing f ON f.id = fd.filing_id
JOIN sec_edgar_companyinfo ci ON ci.company_id = f.company_id AND ci.date = f.date_filed 
WHERE sqr.search_query_id = {0}
ORDER BY f.date_filed, f.company_id
""".format(search_query_id)
    query_df = pandas.read_sql(query_string, django.db.connection)
    query_df.to_csv(output_file_path, encoding="utf-8", index=False)