File: init.py

package info (click to toggle)
pyamf 0.6.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,692 kB
  • sloc: python: 17,944; xml: 455; makefile: 116; sql: 38; java: 11; sh: 7
file content (52 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright (c) The PyAMF Project.
# See LICENSE.txt for details.

"""
Creates the database for the RecordSet example.

@since: 0.1.0
"""

import db

def init_data(engine):
    languages = [
        (".java", "Sun Java programming language", "Java",),
        (".py", "Python programming language", "Python",),
        (".php", "PHP programming language", "PHP",),
    ]
    
    software_info = [
        ("Red5", True, "Red5 is an open source Flash media server with RTMP/AMF/FLV support.", ".java", "http://osflash.org/red5",),
        ("RTMPy", True, "RTMPy is an RTMP protocol for the Twisted framework.", ".py", "http://rtmpy.org",),
        ("SabreAMF", True, "SabreAMF is an AMF library for PHP5.", ".php", "http://osflash.org/sabreamf",),
        ("Django", True, "Django is a high-level Python Web framework.", ".py", "http://djangoproject.com",),
        ("Zend", True, "Zend is an open source PHP framework.", ".php", "http://framework.zend.com",),
    ]

    for language in languages:
        ins = db.language.insert(values=dict(ID=language[0],
            Description=language[1], Name=language[2]))

        engine.execute(ins)

    for software in software_info:
        name, active, details, cat_id, url = software
 
        ins = db.software.insert(values={
            'Name': name, 'Active': active, 'Details': details,
            'CategoryID': cat_id, 'Url': url})

        engine.execute(ins)

def main():
    engine = db.get_engine()

    print "Creating database..."
    db.create(engine)

    init_data(engine)
    print "Successfully set up."

if __name__ == '__main__':
    main()