Retrieve data from sqlite db, that is used in android applications in general
Program to retrieve the data from sqlite db:
For this make sure that the placed in the same folder as the program.
import sqlite3conn = sqlite3.connect('master.db')cursor = conn.cursor()cursor.execute("SELECT count(id) FROM table")value = cursor.fetchone()print (value)cursor.close()conn.close()
output will be like this :
200
Most commonly used Encoding and Decoding with b64:
In most of the encryption mechanisms we need to encode the data before encrypting the data. So most commonly and widely used encoding method is base64. So here is the base 64 encoding and decoding logics
Encoding:
import base64
encod_str=base64.b64encode("test")
s= encod_str.decode("utf-8")
print (s)
output will come like this :
u'dGVzdA=='
Decoding:
In this case we are taking the encoded string from above code that is 's'
In this case we are taking the encoded string from above code that is 's'
import base64
decod_str=base64.b64decode(s)
print (decod_str)
output will come like this :
'test'
No comments:
Post a Comment