@@ -43,7 +43,6 @@ def tweet(twitter_profile, business_id, last_tweet_time):
4343    while  True :
4444        try :
4545            c  =  tw .next ()
46-             # print c 
4746            user  =  c .user .screen_name .encode ('utf-8' )
4847            tm  =  c .created_at 
4948
@@ -54,6 +53,7 @@ def tweet(twitter_profile, business_id, last_tweet_time):
5453            #     old_tweet_time = datetime.strptime(last_tweet_time, '%Y-%m-%d %H:%M:%S') 
5554            # except: 
5655            #     old_tweet_time = datetime.strptime('1', '%d') 
56+ 
5757            if  tm  >  last_tweet_time :
5858                print  business_id , user , tm , data , fc , rt 
5959
@@ -63,11 +63,11 @@ def tweet(twitter_profile, business_id, last_tweet_time):
6363
6464                """Insert data into DB""" 
6565
66-                 sql = ("insert into public.tweet(id, username, time, tweet, r, f)  values('%s','%s','%s','%s','%s','%s')" % (business_id , user , tm , data , fc , rt ))
66+                 sql   =   ("insert into public.tweet(id, username, time, tweet, r, f)  values('%s','%s','%s','%s','%s','%s')" % (business_id , user , tm , data , fc , rt ))
6767                cur .execute (sql )
6868                con .commit ()
6969
70-             elif  tm == last_tweet_time :
70+             elif  tm   ==   last_tweet_time :
7171                print  "No New Tweets Updated " 
7272            else :
7373                break 
@@ -118,8 +118,8 @@ def checkdb(tname):
118118    cur .execute (sql )
119119    rows  =  cur .fetchall ()
120120
121-     de = []
122-     li = []
121+     de   =   []
122+     li   =   []
123123    for  r  in  rows :
124124        de .append (r [0 ].lower ())
125125        li .append (r [0 ])
@@ -129,13 +129,13 @@ def checkdb(tname):
129129
130130    if  tname .lower () in  de :
131131        print  "Previoius Data Found for the given Twitter Profile name" 
132-         j = de .index (tname .lower ())
133-         cur .execute ("select distinct id from public.tweet where username='%s'" % li [j ])
134-         r = cur .fetchall ()
135-         b_id =  r [0 ][0 ]
136-         cur .execute ("select max(time) from public.tweet"  )
137-         r = cur .fetchall ()
138-         ti = r [0 ][0 ]
132+         j   =   de .index (tname .lower ())
133+         cur .execute ("select distinct id from public.tweet where username='%s'"   %   li [j ])
134+         r   =   cur .fetchall ()
135+         b_id   =  r [0 ][0 ]
136+         cur .execute ("select max(time) from public.tweet where id='%s'"    %   b_id )
137+         r   =   cur .fetchall ()
138+         ti   =   r [0 ][0 ]
139139        """Get the business_id and max(time) !""" 
140140        print  b_id , ti 
141141        """Call the tweet function with username and  business_id and time from the DB""" 
@@ -145,7 +145,7 @@ def checkdb(tname):
145145        alltweets ()
146146
147147    """Below If works if the DB is empty""" 
148-     if  len (de )== 0 :
148+     if  len (de )  ==   0 :
149149        alltweets ()
150150
151151
@@ -154,14 +154,14 @@ def checkdb(tname):
154154
155155def  alltweets ():
156156    print  "No previous data for given profile\n " 
157-     b_id = input ("Enter Business Id" )
157+     b_id   =   input ("Enter Business Id" )
158158    ti  =  datetime .strptime ('1' , '%d' )
159-     tweet (twitter_profile_name ,b_id ,ti )
159+     tweet (twitter_profile_name ,  b_id ,  ti )
160160
161161
162162
163163"""Enter the twitter Profile """ 
164- twitter_profile_name = 'TSmoothieCafe '
164+ twitter_profile_name   =   'firebrewva '
165165
166166checkdb (twitter_profile_name )
167167
0 commit comments