Massenqueue kann ab jetzt uebergeben werden
This commit is contained in:
parent
82a1b9dc69
commit
42f14e9d8d
1 changed files with 33 additions and 20 deletions
|
@ -20,7 +20,6 @@ class DataBase:
|
|||
|
||||
def get_latest_uid_category(self, type):
|
||||
c = self.db.cursor()
|
||||
#c.execute("""SELECT uid FROM tx_skcalendar_category""")
|
||||
sqlqueue="SELECT uid FROM tx_skcalendar_" + type
|
||||
c.execute(sqlqueue)
|
||||
j=1
|
||||
|
@ -33,22 +32,35 @@ class DataBase:
|
|||
def prepare_event(self):
|
||||
'''hiermit wird eine neue Veranstaltung in passender Form
|
||||
fuer die VCE Extension vorbereitet'''
|
||||
self.event_pid = "29"
|
||||
self.event_title = "Test2"
|
||||
self.event_description = "blablabla"
|
||||
self.event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple())))
|
||||
self.event_targetgroup = "5"
|
||||
self.event_category = "1"
|
||||
self.event_organizer = "1"
|
||||
self.event_location = "1"
|
||||
self.event_tstamp = str(int(mktime(datetime.now().timetuple())))
|
||||
self.event_crdate = str(int(mktime(datetime.now().timetuple())))
|
||||
## Testdatensaetze
|
||||
event_pid = "29"
|
||||
event_title = "Test2888888"
|
||||
event_title2= "Test2345345"
|
||||
event_description = "blablabla"
|
||||
event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple())))
|
||||
event_targetgroup = "5"
|
||||
event_category = "1"
|
||||
event_organizer = "1"
|
||||
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):
|
||||
'''den MySQL Befehl absetzen'''
|
||||
#sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid`) VALUES ('29');"
|
||||
self.prepare_event()
|
||||
c = self.db.cursor()
|
||||
#c.execute(sqlqueue)
|
||||
"""
|
||||
sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate` ) VALUES (" \
|
||||
+ "'" + self.event_pid + "', "\
|
||||
+ "'" + self.event_title + "', "\
|
||||
|
@ -60,17 +72,18 @@ class DataBase:
|
|||
+ "'" + self.event_tstamp + "', "\
|
||||
+ "'" + self.event_crdate \
|
||||
+ "');"
|
||||
print sqlqueue
|
||||
c.execute(sqlqueue)
|
||||
## oder wenn werte aus einer liste: users = (bla, fasel, foo, bar)
|
||||
## c.executemany("""INSERT INTO users (userid, first_name, last_name, company) VALUES (%s, %s, %s, %s)""", users)
|
||||
## 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 ) ] )
|
||||
"""
|
||||
c = self.db.cursor()
|
||||
data = self.prepare_event()
|
||||
print "folgende Datensaetze einfuegen:"
|
||||
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__':
|
||||
test = DataBase()
|
||||
test.connect()
|
||||
test.get_latest_uid_category("organizer")
|
||||
#test.prepare_event()
|
||||
#test.get_latest_uid_category("organizer")
|
||||
test.insert_event()
|
||||
test.close()
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in a new issue