How can I apply inventory code?


#1



For lesson 10.13 -- Stocking Out --

I've created the inventory stock code, but I don't know how to actually apply it. It runs and Code Academy validates it, but how can I tie this to something meaningful like a spreadsheet, web form or database? My friends and I want to keep tabs on who has video equipment, what we buy, and what we sell/give away. Any suggestions on how to incorporate code like this into an actual program?



#2

sure python has library's for this, but i never used them

you can do this, i would use a web framework, here is a list. You can connect this to a database (i have done this: django (python web framework) + gunicorn (glue) + postgresql (database) + nginx (webserver)), or you can use something like heroku to host the website, a bit easier to do

If you just want a simple database you can use sqlite(3), you can write a simple program to retrieve data from the sqlite database. A lot simpler then configuring a entire webserver like i mentioned above.

So many options, i personally think a simple sqlite3 database is the easiest solution, but then i haven't used spreadsheets, which sounds more challenging.


#3

Hi,

I'm afraid you'll need to do some googling on your own. There are numerous ways to solve your problem — some easier, some harder. An easy thing here would be to create a spreadsheet containing values from your Python file, and a very hard thing would be using one of frameworks like web.py or django to create a web form, where you'd put things and they would show up on the page in a table or something. A colleague above mentioned connecting things to database and stuff — that's, uhm, real hard.

I think that in your case the easiest thing would be to save things into a spreadsheet, so csv file probably, since a txt file would be kind of messy probably.

In this case you need to research writing files by python (as in, how to make a python code write in a file), and the library called 'csv'. An example of a such file might be found here: http://stackoverflow.com/questions/8685809/python-writing-a-dictionary-to-a-csv-file-with-one-line-for-every-key-value

In any case, basically start by sitting down and thinking what exactly you want to accomplish — do you need a thing that is connected to the web or that can be just kept on a PC? Do you need to automate some things? If yes, what kind of? Etc — and then you'll get an idea of what you need, and then you can research things based on that.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.