Ejemplo n.º 1
0
#insert_data.py
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

# create a Session
Session = sessionmaker(bind=engine)
session = Session()

# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Read All About It", "Rock", "Refuge", "CD")]

# add more albums
more_albums = [
    Album("Hell Is for Wimps", "Rock", "Star Song", "CD"),
    Album("Love Liberty Disco", "Rock", "Sparrow", "CD"),
    Album("Thrive", "Rock", "Sparrow", "CD")
]
new_artist.albums.extend(more_albums)

# Add the record to the session object
session.add(new_artist)
# commit the record the database
session.commit()

# Add several artists
session.add_all(
Ejemplo n.º 2
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

# create a Session
Session = sessionmaker(bind=engine)
session = Session()

# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [
    Album("Read All About It", datetime.date(1988, 12, 01), "Refuge", "CD")
]

# add more albums
more_albums = [
    Album("Hell Is for Wimps", datetime.date(1990, 07, 31), "Star Song", "CD"),
    Album("Love Liberty Disco", datetime.date(1999, 11, 16), "Sparrow", "CD"),
    Album("Thrive", datetime.date(2002, 03, 26), "Sparrow", "CD")
]
new_artist.albums.extend(more_albums)

# Add the record to the session object
session.add(new_artist)
# commit the record the database
session.commit()

# Add several artists
Ejemplo n.º 3
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
 
engine = create_engine('sqlite:///mymusic.db', echo=True)

from table_def import Album, Artist
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Read All About It", 
                           datetime.date(1988,12,01),
                           "Refuge", "CD")]
 
# add more albums
more_albums = [Album("Hell Is for Wimps",
                     datetime.date(1990,07,31),
                     "Star Song", "CD"),
               Album("Love Liberty Disco", 
                     datetime.date(1999,11,16),
                     "Sparrow", "CD"),
               Album("Thrive",
                     datetime.date(2002,03,26),
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
Ejemplo n.º 4
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

#Create a Session
Session = sessionmaker(bind=engine)
session = Session()

#Create an Artist
new_artist = Artist("Rebelution")
new_artist.albums = [Album("Bright Side of Life", "Reggae", "Controlled Substance Sound Lab", "CD")]

#Add more albums
more_albums = [Album("Peace of Mind", "Reggae", "87 Music", "CD")]
new_artist.albums.extend(more_albums)

#Add the record to the session object
session.add(new_artist)
#commit
new_artist2 = Artist("Eminem")
new_artist2.albums = [Album("The Eminem Show", "Rap", "Shady Records", "CD")]
new_artist3 = Artist("Sum 41")
new_artist3.albums = [Album("Does This Look Infected?", "Punk", "Island Records", "CD")]
new_artist4 = Artist("Katy Perry")
new_artist4.albums = [Album("One of the Boys", "Pop", "Capitol Music Group", "CD")]
session.add(new_artist2)
session.add(new_artist3)
session.add(new_artist4)
Ejemplo n.º 5
0
# table_pop.py

import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic2.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Tiesto")
new_artist.albums = [Album("Escape Me", 
                           "Trance",
                           "NA", "CD")]
 
# add more albums
more_albums = [Album("Hell Is for Wimps",
                     "rock",
                     "Star Song", "CD"),
               Album("Love Liberty Disco", 
                     "testing",
                     "Sparrow", "CD"),
               Album("Thrive",
                     "testing",
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
Ejemplo n.º 6
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Read All About It", 
                           'some genre',
                           "Refuge", "CD")]
 
# add more albums
more_albums = [Album("Hell Is for Wimps",
                     "some genre",
                     "Star Song", "CD"),
               Album("Love Liberty Disco", 
                     'and another genre',
                     "Sparrow", "CD"),
               Album("Thrive",
                     'so genre',
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
session.add(new_artist)
Ejemplo n.º 7
0
# add_data.py
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

# create a Session
Session = sessionmaker(bind=engine)
session = Session()

# Create an artist
new_artist = Artist(name="Newsboys")
new_artist.albums = [Album(title="Read All About It",
                           release_date=datetime.date(1988,12,1),
                           publisher="Refuge", media_type="CD")]

# add more albums
more_albums = [Album(title="Hell Is for Wimps",
                     release_date=datetime.date(1990,7,31),
                     publisher="Star Song", media_type="CD"),
               Album(title="Love Liberty Disco",
                     release_date=datetime.date(1999,11,16),
                     publisher="Sparrow", media_type="CD"),
               Album(title="Thrive",
                     release_date=datetime.date(2002,3,26),
                     publisher="Sparrow", media_type="CD")]
new_artist.albums.extend(more_albums)

# Add the record to the session object
Ejemplo n.º 8
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

# create a session
Session = sessionmaker(bind=engine)
session = Session()

# create an artist
new_artist = Artist(name="Newsboys")
new_artist.albums = [
    Album(title="Read All About It",
          release_date=datetime.date(1988, 12, 1),
          publisher="Refuge",
          media_type="CD")
]

# add more albums
more_albums = [
    Album(title="Hell Is for Wimps",
          release_date=datetime.date(1990, 7, 31),
          publisher="Star Song",
          media_type="CD"),
    Album(title="Love Liberty Disco",
          release_date=datetime.date(1999, 11, 16),
          publisher="Sparrow",
          media_type="CD"),
    Album(title="Thrive",
Ejemplo n.º 9
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Coldplay")
new_artist.albums = [Album("Mylo Xyloto", 
                           "Pop",
                           "Parlophone Records", "CD")]
 
# add more albums
more_albums = [Album("A Rush of Blood to the Head",
                     "Alternative",
                     "Parlophone Records", "CD")]
new_artist.albums.extend(more_albums)

# Add the record to the session object
session.add(new_artist)
# commit the record the database
session.commit()

# Add several artists
session.add_all([
    Artist("The Script"),
Ejemplo n.º 10
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
 
engine = create_engine('sqlite:///mymusic.db', echo=True)

from table_def import Album, Artist
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Loreena Mckinnet")
new_artist.albums = [Album("Mystic Dream", 
                           "folk",
                           "star", "CD")]
 
# add more albums
more_albums = [Album("Singer",
                     "folk",
                     "Star", "CD"),
               Album("Dancer", 
                     "celtic",
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
session.add(new_artist)
# commit the record the database
session.commit()
Ejemplo n.º 11
0
'''

import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

#create a Session
#Our handle to the database and let's us interact with it.
Session = sessionmaker(bind=engine)
session = Session()

#Create an artist
new_artist = Artist(name="Bone Thugs and Harmony")
new_artist.albums = [
    Album(title="E.1999 Eternal",
          release_date=datetime.datetime.now(),
          publisher="Ruthless Records",
          media_type="CD")
]

#add more albums
more_albums = [
    Album(title="The Crossroads",
          release_date=datetime.datetime.now(),
          publisher="Ruthless Records",
          media_type="CD")
]
Ejemplo n.º 12
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Read All About It", 
                           datetime.date(1988,12,01),
                           "Refuge", "CD")]
 
# add more albums
more_albums = [Album("Hell Is for Wimps",
                     datetime.date(1990,07,31),
                     "Star Song", "CD"),
               Album("Love Liberty Disco", 
                     datetime.date(1999,11,16),
                     "Sparrow", "CD"),
               Album("Thrive",
                     datetime.date(2002,03,26),
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
session.add(new_artist)
Ejemplo n.º 13
0
#insert_data.py
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Read All About It", 
                           "Rock",
                           "Refuge", "CD")]
 
# add more albums
more_albums = [Album("Hell Is for Wimps",
                     "Rock",
                     "Star Song", "CD"),
               Album("Love Liberty Disco", 
                     "Rock",
                     "Sparrow", "CD"),
               Album("Thrive",
                     "Rock",
                     "Sparrow", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
Ejemplo n.º 14
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist
 
engine = create_engine('sqlite:///mymusic.db', echo=True)
 
# create a Session
Session = sessionmaker(bind=engine)
session = Session()
 
# Create an artist
new_artist = Artist("Newsboys")
new_artist.albums = [Album("Live Love A ", 
                          "Rap",
                           "ASAP Rocky", "CD")]
 
# add more albums
more_albums = [Album("I am not a human being",
                     "Rap",
                     "Lil Wayne", "CD"),
               Album("Title and Registration", 
                     "Country",
                     "Death Cab for Cutie", "CD"),
               Album("Curtain Call: The Hits",
                     "Country",
                     "Eminem", "CD")]
new_artist.albums.extend(more_albums)
 
# Add the record to the session object
session.add(new_artist)
Ejemplo n.º 15
0
import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from table_def import Album, Artist

engine = create_engine('sqlite:///mymusic.db', echo=True)

# create a Session
Session = sessionmaker(bind=engine)
session = Session()

# Create an artist
new_artist1 = Artist("The Strokes")
new_artist1.albums = [Album("Room on fire",
                           "Alternative",
                           "Paramount", "CD")]

new_artist2 = Artist("Newsboys")
new_artist2.albums = [Album("Read All About It",
                           "Country",
                           "Refuge", "CD")]
new_artist3 = Artist("Pinback")
new_artist3.albums = [Album("Summer in Abaddon",
                           "Alternative",
                           "Parrapa", "CD")]

# add more albums
more_albums = [Album("Hell Is for Wimps",
                     "Country",
                     "Star Song", "CD"),
               Album("Love Liberty Disco",