Last active
June 13, 2016 00:44
-
-
Save dguzzo/6afe6c83fc83ddc4f66904b3d96a362c to your computer and use it in GitHub Desktop.
put some colors from colourlovers.com into a sqlite database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Library/Frameworks/Python.framework/Versions/3.4/bin/python3 | |
# -*- coding: utf-8 -*- | |
import sqlite3 as lite | |
from colourlovers import ColourLovers | |
def getColors(): | |
cl = ColourLovers() | |
colors = cl.colors() | |
return tuple([(color.title, color.hex) for color in colors]) | |
colors_tuple = getColors() | |
con = lite.connect('colors.db') | |
with con: | |
cur = con.cursor() | |
cur.execute("DROP TABLE IF EXISTS Colors") | |
cur.execute("CREATE TABLE Colors(Id INTEGER PRIMARY KEY, Title TEXT, Hex TEXT UNIQUE)") | |
cur.executemany("INSERT INTO Colors(Title, Hex) VALUES(?, ?)", colors_tuple) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment