This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env/python | |
import psycopg2 | |
import os | |
from io import StringIO | |
import pandas as pd | |
# Get a database connection | |
dsn = os.environ.get('DB_DSN') # Use ENV vars: keep it secret, keep it safe | |
conn = psycopg2.connect(dsn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://hakibenita.com/fast-load-data-python-postgresql | |
from typing import Iterator, Dict, Any, Optional | |
from urllib.parse import urlencode | |
import datetime | |
#------------------------ Profile | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import clr | |
sys.path.append(r'C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0') | |
clr.AddReference('OSIsoft.AFSDK') | |
from OSIsoft.AF import * | |
from OSIsoft.AF.PI import * | |
from OSIsoft.AF.Asset import * | |
from OSIsoft.AF.Data import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
'''Creates a zip archive of your Pythonista files and serves them via HTTP in your local network.''' | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
import os | |
import shutil | |
import tempfile | |
import shutil | |
PORT = 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import re, MySQLdb | |
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" ) | |
# | |
# MySQL Code | |
# CREATE TABLE keyword (keywordid integer primary key auto_increment, keyword VARCHAR(255) NOT NULL); | |
# | |
# CREATE TABLE location (companyid integer, pdfid integer, keywordid integer references keyword(keywordid), |