Skip to main content

Posts

Showing posts from 2019

Use .htaccess to Redirect to HTTPS

If you are using apache webserver and would like to redirect all your traffic to the Secured Socket Layer protocol SSL, you may do that by editing the .htaccess file which resides on the html root of your hosting directory. To do so please add the below lines to your .htaccess file: #HTTPS Redirect <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> #End HTTPS Redirect

Connect Jupyter Notebook Pandas to Postgres

First install Python library Psycopg2 to connect to PostgreSQL: !pip install psycopg2 Now import the necessary libraries: import pandas as pd import psycopg2 as pg import pandas.io.sql as psql Connect to the DB Server: conn = pg.connect("postgres://username:password@server:port/dbname") Execute a Query: df = pd.read_sql('select* from table_name', conn) df.head()