Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 20th, 2006, 8:48 AM   #1
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
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:
(9,1,0,'CM00','A compressor for an SB-III','Compressor for an SB-III. Rebuilt and ready to use.','d75898348851e9d9820a1800d2c6d466.png',
'b94ba316eba27aa3a9ac650fabf79346.jpg','Y','0.0000','pounds',
'0.0000','0.0000','0.0000','inches','',0,1156305600,'','N',0,NULL,1156342698,1156342698,
'Compressor',0,'','',2,'piece',0),
So from what I can piece together, the syntax would be this:

Quote:
(9,1,0,'Product ID',' Short Description','thumbnail photo',
'large photo','Y','0.0000','pounds', //Measurements
'0.0000','0.0000','0.0000','inches','',0,1156305600,'','N',0,NULL,1156342698,1156342698,
'Item type',0,'','',2,'Item category',0),
Thanks everyone!
bulio is offline   Reply With Quote
Old Oct 20th, 2006, 9:07 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 20th, 2006, 9:10 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I would access the db directly, using PHPMyAdmin, or similar, and add products via a file.

EDIT: Woops, IR is on the same wavelength.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 20th, 2006, 11:40 AM   #4
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
Quote:
Originally Posted by Infinite Recursion View Post
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.
So I first need to find out the description of each table field. Next, what module would I use to write to the mysql DB? (I'd need to connect to the DB via the internet). I would then prompt the user for information and store the information as variables. At the end, I would send the variables to the DB and have a new product created. Correct?
bulio is offline   Reply With Quote
Old Oct 20th, 2006, 12:51 PM   #5
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
I would have edited my above message, but it is older than 60 mins

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
bulio is offline   Reply With Quote
Old Oct 20th, 2006, 1:31 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 20th, 2006, 1:34 PM   #7
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
Quote:
Originally Posted by DaWei View Post
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.
I haven't looked at it yet, although I can install it on the server if I want to (I think I'll take a look at it once the website is fully operational). I'd preferrably want to go the Python route, as It would be much faster than clicking around a web interface to add a product. I will be adding around 50 products a week and I think having a simple command-line utility would probably do the trick.
bulio is offline   Reply With Quote
Old Oct 20th, 2006, 1:35 PM   #8
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 20th, 2006, 1:52 PM   #9
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
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)
bulio is offline   Reply With Quote
Old Oct 20th, 2006, 2:15 PM   #10
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
I'll throw it around a bit also... been curious about it. Let us know if you run into problems.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:14 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC