Guest User

Untitled

a guest
Mar 5th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #!/usr/bin/python
  2. import mysql.connector as mariadb
  3.  
  4. def insert_channels(mariadb_connection, number_of_channels, levels):
  5. cursor = mariadb_connection.cursor()
  6.  
  7. for root in range(10, 16):
  8. cursor.execute('INSERT INTO channel values ({}, NULL, 1, 0, NULL)'.format(root))
  9. for id1 in range(root*10, root*10+10):
  10. cursor.execute('INSERT INTO channel values ({}, {}, 1, 0, NULL)'.format(id1, root))
  11. for id2 in range((root+id1)*100, (root+id1)*100+10):
  12. cursor.execute('INSERT INTO channel values ({}, {}, 1, 0, NULL)'.format(id2, id1))
  13. for id3 in range((root+id1+id2)*1000, (root+id1+id2)*1000+10):
  14. cursor.execute('INSERT INTO channel values ({}, {}, 1, 0, NULL)'.format(id3, id2))
  15. mariadb_connection.commit()
  16.  
  17. cursor.execute("SELECT id, channel_id, video_manager_id FROM channel WHERE video_manager_id=1")
  18. for (id, channel_id, video_manager_id) in cursor:
  19. print("id: {}, channel_id: {}, video_manager_id: {}").format(id, channel_id, video_manager_id)
  20.  
  21. def main():
  22. mariadb_connection = mariadb.connect(host='192.168.99.100', user='root', password='admin', database='vam')
  23. insert_channels(mariadb_connection, 100, 5)
  24.  
  25. if __name__ == "__main__":
  26. main()
Add Comment
Please, Sign In to add comment