Massenqueue kann ab jetzt uebergeben werden

This commit is contained in:
age 2008-01-11 20:06:06 +00:00
parent 82a1b9dc69
commit 42f14e9d8d

View file

@ -20,7 +20,6 @@ class DataBase:
def get_latest_uid_category(self, type): def get_latest_uid_category(self, type):
c = self.db.cursor() c = self.db.cursor()
#c.execute("""SELECT uid FROM tx_skcalendar_category""")
sqlqueue="SELECT uid FROM tx_skcalendar_" + type sqlqueue="SELECT uid FROM tx_skcalendar_" + type
c.execute(sqlqueue) c.execute(sqlqueue)
j=1 j=1
@ -33,22 +32,35 @@ class DataBase:
def prepare_event(self): def prepare_event(self):
'''hiermit wird eine neue Veranstaltung in passender Form '''hiermit wird eine neue Veranstaltung in passender Form
fuer die VCE Extension vorbereitet''' fuer die VCE Extension vorbereitet'''
self.event_pid = "29" ## Testdatensaetze
self.event_title = "Test2" event_pid = "29"
self.event_description = "blablabla" event_title = "Test2888888"
self.event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple()))) event_title2= "Test2345345"
self.event_targetgroup = "5" event_description = "blablabla"
self.event_category = "1" event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple())))
self.event_organizer = "1" event_targetgroup = "5"
self.event_location = "1" event_category = "1"
self.event_tstamp = str(int(mktime(datetime.now().timetuple()))) event_organizer = "1"
self.event_crdate = str(int(mktime(datetime.now().timetuple()))) event_location = "1"
event_tstamp = str(int(mktime(datetime.now().timetuple())))
event_crdate = str(int(mktime(datetime.now().timetuple())))
# felder ohne default wert mit leerem string besetzen
event_image = ""
event_link = ""
event_exeptions = ""
event_l18n_diffsource = ""
# liste fuer alle datensaetze zusammenstellen
#TODO aus xml holen
event1 = (event_pid, event_title, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
event2 = (event_pid, event_title2, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
event_data = [ event1, event2 ]
return event_data
def insert_event(self): def insert_event(self):
'''den MySQL Befehl absetzen''' '''den MySQL Befehl absetzen'''
#sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid`) VALUES ('29');" #sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid`) VALUES ('29');"
self.prepare_event() #c.execute(sqlqueue)
c = self.db.cursor() """
sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate` ) VALUES (" \ sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate` ) VALUES (" \
+ "'" + self.event_pid + "', "\ + "'" + self.event_pid + "', "\
+ "'" + self.event_title + "', "\ + "'" + self.event_title + "', "\
@ -60,17 +72,18 @@ class DataBase:
+ "'" + self.event_tstamp + "', "\ + "'" + self.event_tstamp + "', "\
+ "'" + self.event_crdate \ + "'" + self.event_crdate \
+ "');" + "');"
print sqlqueue """
c.execute(sqlqueue) c = self.db.cursor()
## oder wenn werte aus einer liste: users = (bla, fasel, foo, bar) data = self.prepare_event()
## c.executemany("""INSERT INTO users (userid, first_name, last_name, company) VALUES (%s, %s, %s, %s)""", users) print "folgende Datensaetze einfuegen:"
## oder c.executemany( """INSERT INTO breakfast (name, spam, eggs, sausage, price) VALUES (%s, %s, %s, %s, %s)""", [ ("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ), ("Not So Much Spam Plate", 3, 2, 0, 3.95 ), ("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 ) ] ) for i in data:
print i
c.executemany("""INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `startdate`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate`, `image`, `link`, `exeptions`, `l18n_diffsource`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", data)
if __name__ == '__main__': if __name__ == '__main__':
test = DataBase() test = DataBase()
test.connect() test.connect()
test.get_latest_uid_category("organizer") #test.get_latest_uid_category("organizer")
#test.prepare_event()
test.insert_event() test.insert_event()
test.close() test.close()
sys.exit(0) sys.exit(0)