0

So my data is stored in a mySQL database (on a local server). Im wondering what are the steps I need to complete in order to make the package available to other users? Like from GitHub? Since the package relies on the database content, I assume public users wouldn't be able to use the package. Or would they? Sorry I'm really new to this, so I am really unsure of the procedures.

Aerole
  • 105
  • 2
  • 10
  • Check out [How to include MySQL database schema on Github](https://stackoverflow.com/questions/16288579/how-to-include-mysql-database-schema-on-github) – LinkBerest Jul 11 '15 at 01:11

1 Answers1

1

Your best best is ship the package with the following:

  • fixtures which will contain data you application needs
  • script to insert the "fixtures" in the user of your package

fixtures

There are many ways to do this. I personally like how Django does fixtures as they are simple json files. Alternatively you can supply "fixtures" as SQL scripts, model instances, etc.

script

The purpose of the script is to install the fixtures packaged within your project in the database. It will essentially read the fixture data in whatever format you decide to store it, loop over it and insert in the configured database.

package

You will need to include some additional configurations in your setup.py in order for your package to include both the fixture files as well as the insert script:

  • data files:

    setup(...,
        package_data={'mypkg': ['data/*.json']},
    )
    
  • script file:

    setup(...,
        scripts=['scripts/fixture_load.py']
    )
    

Then when users will install your package (e.g. pip install examplepackage), it will install fixture_load.py script within the users Python environment which they will run to insert the fixture data.

miki725
  • 27,207
  • 17
  • 105
  • 121
  • Are there any resources where I can learn more about this as this is my first time attempting this. – Aerole Jul 18 '15 at 05:43
  • I'm just a bit confused about fixtures in general since its my the first time hearing about them. – Aerole Jul 18 '15 at 05:49
  • The answer includes a link to Django fixtures. That might get you started – miki725 Jul 18 '15 at 11:49
  • Ok so after reading it I have a few questions. From my understanding, I would need to install django in order to make use of their manage.py dumpdata command. It seems to be the simplest way to dump data from database to a file in json format (default). Now after the data is dumped in a file, why would we want to insert it into a database after ? Does this mean the user needs to have a mysql database server on their system ? I was intending to write a few functions that perform a number of tasks using the database, and then give the user these functions. – Aerole Jul 19 '15 at 03:20