<commit_before>---
layout: post
title: Connecting Postgresql
excerpt: "Connect to Postgresql using Python"
comments: false
---

**Connect to Postgresql using Python**
First thing is to install psycopg2 module by typing the following command: 

    sudo apt-get install python-psycopg2
Next open a python file and and use the following code:

    import psycopg2
    import psycopg2.extras
    import os
    
    def db_connect():
        print 'connection to the db_connect'
        connectionString='dbname=ecom user=usman password=<PASSWORD> host=localhost'
        try:
            print 'are we trying'
            return psycopg2.connect(connectionString)<commit_msg>connecting postgresql<commit_after>---
layout: post
title: Connecting Postgresql
excerpt: "Connect to Postgresql using Python"
comments: false
---
**Connect to Postgresql using Python**
First thing is to install psycopg2 module by typing the following command: 

    sudo apt-get install python-psycopg2

Next open a python file and and use the following code:

    import psycopg2
    import psycopg2.extras
    import os
    
    def db_connect():
        print 'connection to the db_connect'
        connectionString='dbname=ecom user=usman password=<PASSWORD> host=localhost'
        try:
            print 'are we trying'
            return psycopg2.connect(connectionString)
{'fraction_non_alphanumeric': 0.0650887573964497, 'fraction_numerical': 0.0073964497041420114, 'mean_word_length': 3.2816455696202533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6630901', 'n_tokens_mistral': 383, 'n_tokens_neox': 371, 'n_words': 140}