![]() |
Best way to do this?
Hi everyone,
I would like to write a command-line program that allows me to input data to my website so that I can add new products without having to use the web-form to add items. The site can be found here: http://coyote-equipment.com I have thought about two possible ways of going about this, and was wondering what you guys think would be the easiest way for a python newbie to do this. The site uses Joomla CMS with a shop module called Virtuemart. 1) Use a python module to connect to the site and automatically fill data in each form depending on what I type in the command line. (Ex: Serial #: 0000 would be placed in the product description field.) 2) Acess the mysql database and create new entries. I did a mysqldump and located an exisisting product to have an idea on how I would add a product. The syntax looks like this: Quote:
Quote:
|
Personally, I'd go with a direct connection to the database. You may want to DESC the table so you have a handle on what the field names are, some of those values look random.
|
I would access the db directly, using PHPMyAdmin, or similar, and add products via a file.
EDIT: Woops, IR is on the same wavelength. |
Quote:
|
I would have edited my above message, but it is older than 60 mins :S
Here are the mysql tables releavant to what I'm planning on doing. I'm not sure which ones affect the addition of a new product though (Except for description and price). http://rafb.net/paste/results/FT1m4e18.html |
I would presume that those things identified by 'product' would be the approriate items. Did you investigate phpMyAdmin? It gives you one hell of a lot of control over your database, including writing your own SQL, modifying the database and/or its contents with files (.csv or other text-based), backing up tables that you might screw up when you modify them, stuff like that. It is often made available by your host, just as a matter of course.
|
Quote:
|
Yes. You will need a description of the fields, with emphasis on the type, null / not null, unique, etc. I don't know much about web development with Python, so I cannot elaborate on which module you would need... Sane would probably be able to answer that for you... I believe he is our resident Python wizard. I personally would have went with PHP for this effort.
Yep. You could either prompt the user for information or parse a master file of new products for a bulkload. Upon submission, you should have a new product (new entry in the DB) created. In regards to the table... any fields that you don't need and are not required by other components (carts, reports, etc) you can place NULL values in manually, or you can selectively specify which columns you want to update in the 'insert' sql statement. EDIT: Fancy meeting you all here... :) PhpMyAdmin is a great tool. I favor the idea of a command line utility for bulk adds. Assuming the backend is MySQL, the module you would need may be MySQLdb. |
Yeah, I've been currently toying with MySQLdb since this morning with Python 2.4, still trying to get it to connect to my mysql server. (I need to fix mysql permissions)
|
I'll throw it around a bit also... been curious about it. Let us know if you run into problems.
|
| All times are GMT -5. The time now is 10:21 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC