Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3 as lite
- def create():
- con = lite.connect('kilo40.db')
- cur = con.cursor()
- p_file = open("photos.txt").readlines()
- result = []
- id_w = ''
- photo_link = ''
- lose = 0
- for elem in p_file:
- try:
- id_w, photo_link = elem.replace('\n', '').split(' : ')
- result.append([int(id_w), photo_link])
- except:
- lose+=1
- print lose
- with con:
- cur.execute("DROP TABLE IF EXISTS Photos")
- cur.execute("CREATE TABLE Photos(Id INT, link TEXT)")
- cur.executemany("INSERT INTO Photos VALUES(?, ?)", result)
- def main():
- con = lite.connect('kilo40.db')
- cur = con.cursor()
- cur.execute("SELECT link FROM Photos WHERE id=9207738")
- rows = cur.fetchall()
- for elem in rows:
- print elem
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement