{"revision": {"id": "f33b7399-2f95-11f1-b294-e86a64d24d78", "node_id": "f33ab6ea-2f95-11f1-ae4e-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Python script to build an Oracle or mySQL flat file vault\r\n================================================================\r\n\r\nThis script will build a 64 by 64 flat filesystem.  The root directory will be named thevault.  \r\n\r\nThis is useful for storing flatfiles like pictures, pdfs, mp3 or autocad drawings and then use the database to store metadata about the files.\r\n\r\n*pyvault.py*\r\n\r\n.. code-block:: python\r\n\r\n from os import makedirs\r\n\r\n root = \"thevault\"\r\n\r\n for i in range( 1, 65 ):\r\n     for j in range( 1, 65 ):\r\n         makedirs( root + '/' + str( i ) + '/' + str( j ) )\r\n\r\nI then normally use uuids for the acutal file names to prevent overwriting or the need to lookup or keep track of names.\r\n\r\nI then have a database table similar to this:\r\n\r\n.. code-block:: python\r\n \r\n vault\r\n    id (int) # auto increment \r\n    name (varchar 64) # human readable lookup name\r\n    location (varchar 128) # thevault/12/59/28c6104f-cb09-4910-8031-efad22e1ebf9\r\n    filetype (varchar 8) # or possibly another table to keep track of file types or possibly add the extension to the uuid filename when saved.\r\n    description (text)\r\n\r\nThen other tables can refer and relate to this data, like a job table could have relations mapped to jpg files and pdf files, and a video of the finished job and an autocad drawing when it was designed.\r\n\r\n\r\n\r\n\r\n", "source_format": "rst", "revision_number": 1, "created": 1297535291000}}