I have simple, 1 table, data source that I want to be able to query through an API.
I want to be able to query on any one of the columns. Ideally, I could query for multiple values per column. One column has text, for which I need to be able to do partial and approximate matches (as well as handle diacriticals)
I am wondering what packages people recommend for building this. I realize its something simple, but it seems like a common enough goal that I thought there would be something available to do all the heavy lifting.
Ideally, I'd like to work with python/django, but could also do PHP. Is there something available to help with this?
I assume since you mentioned django, that you are asking to create a web facing API (like what twitter and facebook provide), if that's the case there are a few options:
You may not have to write anything at all. There are platforms like apigee that allow you to create an API just by clicking a few links. They have free accounts, like almost everyone on the net.
If that doesn't work for you, you can use flask-rest (optimized for the Flask microframework) or tastypie which works great with django for Python. Both will allow you to easily create APIs for your data source and they will take care of most of the boilerplate code for you.
For PHP, someone already asked the same question earlier so that would be a good resource.
If you just want to create an API on top of an existing database and use this API to query the database in other applications, then the de-facto standard for Python is SQLAlchemy.
Probably you may want to check out this link, that will give you some lights about structuring and some template code (in PHP) for building an API:
http://net.tutsplus.com/tutorials/php/creating-an-api-centric-web-application/
From the formatting of the URL to the call of the methods called in it. I.e.:
$controller = ucfirst(strtolower($params['controller']));
import sqlite3
conn = sqlite3.connect("some_db.sqlite")
conn.execute("SELECT * FROM TABLE WHERE some_field=?",('field_value',)) #this should properly escape values
# or
conn.execute("SELECT * FROM TABLE WHERE some_field LIKE ?",('%parial_match%',))
not sure if thats what you are asking for (this is python)
Related
I'm developing an iPhone APP and need to implement also an Web Service.
First of all I'm not a Developer and never made something big in PHP, Objective-C, xCode.
My PHP knowledge isn't also good. But let's start with my Environment.
iPhone APP (xCode 4.2, iOS5), PHP Web Service, MySQL DB
I was researching the WEB and most People tend more to REST than SOAP. I think i see also the advantages of REST (using of simple HTTP Verbs (get, post, delete etc...), but that's not the main point here...
I think I understand the main goal of the REST Architecture and tried to make a little concept with an URI and Verb Mapping. Here just a simple example of the mapping:
/location/{location_id}/product
/location/{location_id}/product/{product_id}
Both are GET operations who should get me ether a single product or all products of a location.
How would a simple PHP REST Web Server look like with these functions?
Another part should implement a User Authentication from the iPhone. Somehow i need to store the user session, right now I don't have any idea how to make that. The goald is that if only a user is logged in, he could review the product.
Now I've researched also the Web but couldn't find an easy step-by-step Tutorial.
Do you know any good Tutorials which will help me achieve my goal? :)
A lot of people prefer using PHP Frameworks like ZEND. This seems very interesting, but it seems like a big package with a lot of modules.
Does someone know exactly which Modules are needed to get my Web Service working?
This is quite a good tutorial, it uses the codeigniter framework which makes the learning curve a bit steeper but makes it a lot more powerful in the long run.
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
If you want to build this the custom way it's actually very easy to do if you want to return information in the JSON format especially for php5 which is generally well supported amongst hosts these days.
Essentially the steps are like this:
Pass in product id via url and retrieve using GET i.e. service.php?product_id=10
Query database and return data for product id that was passed in
Store returned data in an array
Set header content-type to application/json
json_encode the result (json_encode)
That way when you call that url in a browser you will get a nice JSON formatted array result in a key:value pair manner. And as of iOS5 json parser comes with the framework (for earlier versions SBJson is a good framework to use (SB JSON))
I would like to add a feature to a web app I am developing to allow the user to create rules with an expression builder. Such as the one used in Magento (picture in link below).
http://i.stack.imgur.com/ZWgcG.png
I want to allows them to be able to create the expressions or if statements using column names from a table in a Database, then be able to do comparisons and what not. The expression built in the user interface would then evaluate to code that would be evaluated by a PHP script or Javascript or Perl
I searched the web for things like this that are javascript (ajax) based. I figures there has to be a module or something out on the internet somewhere for jQuery or something similar, but I haven't been able to find anything. I am also not quite sure what something like this is called besides "Expression Builder". If there is something like this out there it would save me a lot of time compared to writing it from scratch.
In Mac OS X terms it is called a “predicate editor”, and can be found in Mail.app and iTunes. I had need for one a while ago, and scoured the web from end to end without finding one. I ended up building my own using jQuery, and it looks like this (text is in norwegian, sorry):
Sadly this is used in an internal project and the source code is not available as it is very application-specific. There is a need for a free component like this though, so if I get around to it I will try to clean this up and release it.
This here should be exactly what you're looking for?
Demo: https://github.com/chrisjpowers/business-rules
Code: https://github.com/chrisjpowers/business-rules
https://packagist.org/packages/ruler/ruler
https://github.com/bobthecow/Ruler
This is very similar to magento one and we are going to use it in our laravel application.more guidance for implementation you can find there.
This fits the bill: (jquery) predicate-builder
No mainstream tool out there for PHP... except the ones we make for ourselves :)...Its easy to implement a decent one... Just need to decide where you will store the rules... I had built one for myself with the Rule definition stored in XML ... Then updated it a few months back to store that in JSON .... You write "smarty like" templates for the output you want... 2 cases where I used this was for an Active Record implementation as well as PDF generation ... the move to JSON was because most of the newer usage scenarios were related to throwing out javascript for the pages to consume...
I am trying to create a website that will allow me to list all of the different types of beers I have tried including name, type, location, and brief tasting notes. I have a basic login created and believe that I will have to store the information about the beer in a database as well (with a cell for each of the elements). I was wondering a) if this is how people would suggest going about doing this and b) if anyone knows of good tutorials on how to set this up. I plan on using mySQL and PHP for the database and jQuery for the visual side of things. I am relatively new at this, so I am having trouble figuring out what exactly to Google to find what I am looking for.
I plan on going about it similar to a to-do list (only each element would have multiple attributes — name, type, etc.). Any help/suggestions/direction would be awesome! Thanks!
First off you need to decide on the features you want to implement, and then work out which to do first.
For example,
you need a database, which has a table for your beer info. (but do you need another one for people to have a user account too?)
you need to create a set of functions that you can access from the web site.
list beers
add beer
etc.
How do you want the front end to work?
How do you want the front end to look?
Once you know exactly what you want to do, it's much easier to break down the tasks into jobs you need the application to do.
I'd also suggest you look at Ruby on Rails (especially + the Hobo addon) to get you up and running faster (instead of PHP) - if you are set on PHP, have a look at CakePHP or another similar framework, so that you don't end up re-inventing the wheel.
Update:
Once you get started, further more detailed problems will be faced, many you can get a quick answer from google or the documentation for the language / database etc. If something is extra tricky, post another question on StackOverflow.
As it is your question is too general for a more specific answer, but if you need any additional info, just yell.
I've been googling around for a really simple way of making what is, in effect, nothing more than an enhanced phpMyAdmin.
In a mysql database, I have:
Name, address, phone, website etc, plus 2 or 3 custom fields. This data is pulled out to make a website.
All I want is to be able to make a freeform form, a bit like Access, but for the web, and the only thing I want to do over and above normal field editing would be to have a list of when I contact them, what was said, and perhaps a reminder when the next action is due. It also needs to implement some basic permissions so that different users can access different subsets of the data.
I've looked at so many CRMs my mind is boggling, and they all do WAY more than I need. I don't have leads or accounts, all I have is the need to make sure than when I update the person's details, and for that data to be in the same DB as my site is generate from.
I'm happy to learn if I can get pointed in the right direction, and I have a feeling that something like what I want might lie in the direction of jquery. It's just that there's so much good jquery stuff about, I can't see the wood for the trees!
Thanks.
If phpMyAdmin doesn't quite do it for you, it sounds like you just want a simple little web application.
jQuery is probably barking up the wrong tree. It's just a javascript library. While you could certainly use it to spiff up your little application, it's not going to get you the core functionality you need.
I would just dig in and write a little PHP script that does exactly what you want. Even if you're not very experienced, this would be a great learning project.
There are lots of tools which will generate forms including Phpeanuts, phpFormGen, Delphi for PHP, PfP Studio, FormFields, phpMyEdit (and many more).
I've not looked at Radria for some time - previously, it was more of a CMS/page layout/mashup thing rather than a form generator though.
C.
As has been said, you need to build a web interface.
One simple thing you can use is something like Django's admin panel or Ruby on Rails' script/generate scaffold functionality. If you can run Rails or Django, try those.
If you are tied into PHP, consider using one of the PHP frameworks. I'm no expert on them - some of my PHP-using friends have good stuff to say about Symfony (the alternatives: Cake, CodeIgniter, Zend). A bit of random Googling tells me that Symfony has an admin generator that may be quite like that of Django.
As has been said, jQuery won't do what you need, although you can use it.
I have a MySQL database that has a few very simple tables.
I would like to find an app (implemented in Perl, Python or PHP) that will do the following:
Point the app to a database table, and it automatically retrieves the table's schema from the database.
It then generates an HTML view of the table's data. The data is displayed as a grid, with all fields being user-editable. If there are a lot of rows, then it automatically provides pagination.
Bonus points for allowing the user to click a column heading, which would then sort the data by that column.
Bonus points for allowing the data to be filtered by a "where" clause.
I have already looked at a few packages (phpMyAdmin, webmysql), but they do not seem to provide the editable table view. They seem more oriented towards database administrators. What I need is something that's more oriented towards someone who wants to view, enter and modify data.
Use phpGrid. This is all you need.
$dg = new C_DataGrid(“SELECT * FROM orders”, “orderNumber”, “orders”);
$dg -> display();
Outcome:
See if Java NakedObejcts is what you want. http://www.nakedobjects.org
If you can use groovy then Grails can get you jump started. It will build an ORM of your entire DB, build views and your basic CRUD is all built in.
If you have a real aversion to anything thats Java-based then perl's Catalyst can help build all your mappings but might not get you the whole 9 yards. You will need to write some of your basic CRUD, which is easy and can be accomplished by simple following the Catalyst tutorial.
Thanks for the responses, but none of those exactly fit the bill, so I decided to implement it myself.
The result is a new open source project called DWI, which stands for Database Web Interface. It took me about 3 days to get it working, and I did it in about 600 lines of PHP and javascript.
If you want to check it out, it's located at http://code.google.com/p/dwi.
Use CakeApp.com, it does exactly what you want!
CakeApp.com is a rapid development online tool. It's easy to use, no
other software than your browser is needed. Benefit from ER-Diagrams
of others and share your visions too.