Skip to content

Instantly share code, notes, and snippets.

@driscollis
Created July 17, 2014 18:25
Show Gist options
  • Save driscollis/34b2533a5011aacac60a to your computer and use it in GitHub Desktop.
Save driscollis/34b2533a5011aacac60a to your computer and use it in GitHub Desktop.
peewee adding data
import datetime
import peewee
from models import Album, Artist
new_artist = Artist.create(name="Newsboys")
new_artist.save()
album_one = Album(artist=new_artist,
title="Read All About It",
release_date=datetime.date(1988,12,01),
publisher="Refuge",
media_type="CD")
album_one.save()
albums = [{"artist": new_artist,
"title": "Hell is for Wimps",
"release_date": datetime.date(1990,07,31),
"publisher": "Sparrow",
"media_type": "CD"
},
{"artist": new_artist,
"title": "Love Liberty Disco",
"release_date": datetime.date(1999,11,16),
"publisher": "Sparrow",
"media_type": "CD"
},
{"artist": new_artist,
"title": "Thrive",
"release_date": datetime.date(2002,03,26),
"publisher": "Sparrow",
"media_type": "CD"}
]
for album in albums:
a = Album(**album)
a.save()
bands = ["MXPX", "Kutless", "Thousand Foot Krutch"]
for band in bands:
artist = Artist.create(name=band)
artist.save()
#a = Album.insert_many(albums)
# peewee.OperationalError: near ""album"": syntax error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment