project-open-data / db-to-api Goto Github PK
View Code? Open in Web Editor NEWTurns a Database into a Secure, RESTful API
Turns a Database into a Secure, RESTful API
I am very weak in the department of rewrite rules. So, if my current rewrite rule is this:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
and all pages are in the form of http://example.com/controller/action/params/, how should I update the rewrite rules for db-to-api or is it best just to run it along side of the application instead of trying to integrate with? Thanks.
I am new to RESTful API. How would I go about adding an authentication key for making this a private RESTful API?
This can be cribbed from CSV-to-API. Don't forget to use jsonp_callback_filter()
.
I've tried to use this on three different MySQL databases on two different servers, but it always yields the same error message: "Invalid Database." I haven't chased down the source of the problem, though I'm working on it.
Running into what seems like it should be a minor issue.
I am using a MySQL DB outlined here https://github.com/tyronegrandison/DOL-ILAB/blob/master/CREATE%20DATABASE%20DOLILAB
I set the config file as specified in the readme to:
DOLILAB, 'username' => '', 'password' => '', 'server' => 'localhost', 'port' => 8889, 'type' => 'mysql', 'table_blacklist' => array('cache', 'passwords'), 'column_blacklist' => array('password_hint'), ); register_db_api( 'ilab', $args ); When I look up http://localhost:8889/ilab/good.json, I get the error that can be seen here https://drive.google.com/file/d/0B0bPjGaTVcWed1lrb1dGVlpuck0/view?usp=sharingThere are some inconsistencies and formatting problems between CSV to API and DB to API, and I think it would be wise to standardize between the two. Those inconsistencies are:
README.md
or readme.md
?Hi, what are your thoughts about Zend's DB to API library apigility?
https://github.com/zfcampus/zf-apigility-skeleton
@KristenHoney is correct for connect in Oracle?
#14
$args = array(
'name' => '//192.168.96.93:1521/ORCL',
'username' => 'user',
'password' => 'pass',
'type' => 'oracle',
'table_blacklist' => array(),
'column_blacklist' => array(),
);
register_db_api( 'oradw', $args );
I set up the config.php as instructed and I'm getting "Must select a database." Is there nothing else I need to edit?
The PDO connection is being made like such:
new PDO("mysql:host={$db->server};dbname={$db->name}", $db->username, $db->password );
This is obviously not database agnostic, as it needs to be.
If I comment out the code "$name = $this->slugify( $name );" then it works.
[Enhancement] Is there a way to avoid the [database-name] in the request url ?
I mean to specify in the config that this, and only this, database will be used.
The user would then only specify /table[/column][/value].format, with the classical convention that fields between brackets are optional.
e.g., https://github.com/project-open-data/db-to-api/blob/master/includes/class.db-api.php#L234.
This does three things:
Rather than echo "msg"
as is now, would just need to be moved to $this->error( $msg );
to allow pre 5.4 compatability
DB_API has the following two functions:
function render_html( $data ) {
var_dump( $data );
}
function render_xml( $data ) {
echo "XML HERE";
}
These two functions need to actually perform the advertised tasks.
The render_html()
method does not sanitize outputs. If a database field contains <script>alert(1)</script>
, this will lead to code execution in the user's browser.
Simple fix, change from this:
echo "\t<td>$cell</td>\n";
...to this:
$cell = htmlspecialchars($cell);
echo "\t<td>$cell</td>\n";
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.