Parent Directory
|
Revision Log
Revision 1.2 - (view) (download) (as text)
1 : | efrank | 1.1 | ######################################################################### |
2 : | # | ||
3 : | # Puts foundryId and name of top node into the database. This should | ||
4 : | # only be done once and should be done immediately after loading the | ||
5 : | # schema | ||
6 : | # | ||
7 : | ######################################################################### | ||
8 : | |||
9 : | import sys | ||
10 : | from FaST.DbManager import DbManager | ||
11 : | |||
12 : | ######################################################################### | ||
13 : | |||
14 : | if (__name__ == "__main__" ): | ||
15 : | connectStr = raw_input( "Give connect string: " ) | ||
16 : | dbType = raw_input( "Give database type ('oracle' or 'postgres' ): " ) | ||
17 : | name = raw_input( "Give unique name for database (name others will see): ") | ||
18 : | |||
19 : | ## | ||
20 : | # Get a connection and cursor | ||
21 : | ## | ||
22 : | |||
23 : | try: | ||
24 : | mgr = DbManager.getTxMgr( connectStr, dbType ) | ||
25 : | c = mgr.getCursor() | ||
26 : | except: | ||
27 : | print "Could not connect to database or get cursor", connectStr | ||
28 : | sys.exit() | ||
29 : | |||
30 : | ## | ||
31 : | # Establish the foundryId for the database via the KahDatabaseInfo | ||
32 : | # table | ||
33 : | ## | ||
34 : | |||
35 : | try: | ||
36 : | q = "SELECT * from KahDatabaseInfo" | ||
37 : | c.execute( q ) | ||
38 : | row = c.fetchone() | ||
39 : | except: | ||
40 : | print "Could not test status of KahDatabaseInfo table" | ||
41 : | mgr.rollback() | ||
42 : | mgr.close() | ||
43 : | sys.exit() | ||
44 : | |||
45 : | |||
46 : | if (not None == row ): | ||
47 : | print "Database already has KahdatabaseInfo initialized to ", row | ||
48 : | q = "UPDATE KahDatabaseInfo SET foundryType='%s', " \ | ||
49 : | " foundryURL='%s'" % ( "KahDb", name) | ||
50 : | else: | ||
51 : | q = "INSERT into KahDatabaseInfo VALUES ( '%s', '%s' )" % ( "KahDb", name) | ||
52 : | |||
53 : | try: | ||
54 : | print q | ||
55 : | c.execute( q ) | ||
56 : | except: | ||
57 : | print "Could not insert info into KahDatabaseInfo" | ||
58 : | mgr.rollback() | ||
59 : | mgr.close() | ||
60 : | sys.exit() | ||
61 : | |||
62 : | |||
63 : | ## | ||
64 : | # Initialize the top catalogEntry node. | ||
65 : | ## | ||
66 : | |||
67 : | |||
68 : | try: | ||
69 : | q = "SELECT * from KahCatDirEntry where CatDirEntId=0" | ||
70 : | c.execute( q ) | ||
71 : | row = c.fetchone() | ||
72 : | except: | ||
73 : | print "Could not test status of KahCatDirEntry table." | ||
74 : | sys.exit() | ||
75 : | |||
76 : | if (not None == row ): | ||
77 : | print "Database already has top catalog entry initialized to ", row[0] | ||
78 : | q = "UPDATE KahCatDirEntry SET CatName='%s', FullPathName='/%s' "\ | ||
79 : | " WHERE CatDirEntId=0" % (name, name) | ||
80 : | else: | ||
81 : | efrank | 1.2 | q = "INSERT INTO KahCatDirEntry values ('%s', 0, 0, 0, '/%s')" % (name, name) |
82 : | efrank | 1.1 | |
83 : | try: | ||
84 : | print q | ||
85 : | c.execute( q ) | ||
86 : | except: | ||
87 : | print "Could not create top catalogEntry node" | ||
88 : | sys.exit() | ||
89 : | |||
90 : | |||
91 : | mgr.commit() | ||
92 : | mgr.close() | ||
93 : | print "Done." | ||
94 : |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |