Foppe Hemminga 6 lat temu
commit
601771b671
3 zmienionych plików z 129 dodań i 0 usunięć
  1. 107 0
      .gitignore
  2. 14 0
      data.py
  3. 8 0
      database.py

+ 107 - 0
.gitignore

@@ -0,0 +1,107 @@
+# Created by .ignore support plugin (hsz.mobi)
+### Python template
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.idea

+ 14 - 0
data.py

@@ -0,0 +1,14 @@
+import database
+
+
+db = database.db
+cursor = db.cursor()
+query = """SELECT DISTINCT timestamp FROM stocks ORDER BY stocks.timestamp DESC LIMIT 1 OFFSET 1;"""
+cursor.execute(query)
+one_before_latest_entry_datetime = cursor.fetchone()
+query = """SELECT DISTINCT timestamp FROM stocks ORDER BY stocks.timestamp DESC LIMIT 1;"""
+cursor.execute(query)
+latest_entry_datetime = cursor.fetchone(query)
+
+cursor.close()
+db.close()

+ 8 - 0
database.py

@@ -0,0 +1,8 @@
+import os
+import psycopg2
+
+
+database = os.environ.STOCK_DB_DATABASE
+user = os.environ.STOCK_DB_USER
+password = os.environ.STOCK_DB_PASSWD
+db = psycopg2.connect(database=database, user=user, password=password)