can we connect our python script with a database using the url of the database - mysql

can we connect our python script to interact with the database whose url is known.If yes then how we would do that?? and will we be able to interact with the datbase??
I am going to start working on automating a process whic right now is done manually in my company by accessing a datbase and using it for extracting values or data.
Now this is my first day and i don't know from where to start.All that i know is right now i am having a url to database and the database consists of a "query section" where i will feed what i want to search using different fields of the database query page and will get a list matching my search.
i have to use this list in my GUI that i have to develop. for this purpose i need to know how to access a database using its url and how to interact with it.My database is developed using JavaScript
i am a beginner.Please folks help me with this.

You should specify your database first. e.g mysql
then you can use a ORM like SQLALCHEMY to ease the process for you and in that case this is how you address the db, something like:
"mysql://{}:{}#{}:{}"
.format("YOUR_SQL_USERNAME","YOUR_SQL_PASSWORD", "YOUR_SQL_HOST", "YOUR_SQL_PORT")

Related

how do i store and retrieve form data from a wesbite

this is probably something i could have googled; however i thought id start getting more active on chat forums so basically...
I'm almost done with making a family members business website, on the website is an enquiry form; i want to know how i go making that form store the data its given and how i would then retrieve that data?
still doing final touches to the design then im going to start learning the process of deploying it live which is why im posting here to see how to go about it.
It is very vast question, You will need an API to pass the data from Forms to API Server and a Database, that will store the data. It is also called client-server architecture.
Web Forms -> API Server -> Database
You can use either node express, java, python or any language to create API.
You can install the database on the server where you will run the API or you can use any from the cloud like AWS or Heroku, that way you will skip some setups and it will be ready to be used directly in the API.
To store data from an HTML form, you will need a server-side language and a database to save the data to. Some popular options for the server-side language include PHP, Java, and Python.
Once you have chosen a server-side language, you can use it to write code that will process the form data when the form is submitted. This typically involves connecting to a database, creating a table to store the data in, and then inserting the form data into the table.
To retrieve the data from the database, you will need to use a SQL query to fetch the data from the table. You can then use the server-side language to display the data on the website as needed.
It's a good idea to also consider security when handling form data. Make sure to validate and sanitize the form data to prevent any potential security vulnerabilities.

What is the best way to push data from a rest api to an sql database?

I have 2 rest APIs the first one will return an id I can use to get more data from the second one. I want to push the result of the second api to my sql database in phpMyAdmin. what is the best way to do this? should I be writing a script in another programming language? I plan on pushing at least a hundred results.
What language do you use to interact with your rest APIs? Assuming it is a server-side language of some sort, such as PHP, then you would create a database connection in PHP (look up PDO, MySQLi), then you could write a MySQL command such as INSERT INTO to write your data to the MySQL Database.
PHPMyAdmin plays no role, except that it gives you web-based database management for doing things manually (such as view, write, modify, etc).

How to Save an Append or Delete Query in MySQL

So I'm moving from MS Access to MySQL:
In MS Access you can store certain INSERT, DELETE, and UPDATE queries as objects alongside your tables. Thus for anyone who don't understand computers that well, they can click on the objects and automatically run the queries to alter the master table for various business functions.
In MySQL, where and how do you store these queries, I seem to be only able to make tables. When I write a piece of code using the SQL editor, I can only save it to a remote location (such as my local desktop) and not onto the MySQL database, where it's accessible for my coworkers.
If you can't save it onto the server, how would I write a piece of code and execute it within the database that would be easily usable by others.
Thanks
The answer to this question is going to depend on your environment, your users, and your bandwidth to support any given solution. You are gaining a lot by making the switch from Access to MySQL, however you are losing some of the the WYSIWYG features. (e.g., Access forms that can bind directly to your data source.)
There are many approaches:
If your users are more advanced, simply having access to the database using MySQL Workbench may suffice. From there they would have access to run views, stored procedures, or to create their own custom queries.
Another option would be to script your objects using Python and provide a simple gui using TkInter. Python is generally thought of as an easy to use language; with built in suppport for MySQL and TkInter is its "default" interface.
Using the LAMP architecture is another largely popular paradigm using MySQL as the backend database.
There is also nothing stopping you from using Access to link to your MySQL db using MySQL as an external data source.
I hope this provides enough info to help you begin whittling down your options.

can i create a database without mysql on raspberry pi

I've got a raspberry pi with raspbian and all I've done is installed apache2 and created a small web site i want to create a database.
is this possible without using mysql or other database software. i want to use .JS or a text based database
I want to be able to save the contact details in a text format.
can someone point me in the right direction a simple example would be appreciated all online research wants mysql etc
all i want is a simple example as in enter name and submit i want that name to be logged so if name entered again it will say welcome back once i know this mechanism i can add all the other fields. The reason i want this format is so i can see the list that I'm creating.
i just can't get to grips with mysql I've spent months trying to understand mysql but its just not going in so want to simplify the database to minimal workings so i can complete my site. I know .Js isn't so secure but its a demo so security not important at this point any help appreciated
It would be possible to use JSON for your data storage. It will be a key-value storage. On each page view you will have to load the entire file into memory and parse it. From then on it is possible to loop it to search data or get data from a key. This requires no extra software just PHP with Apache.
How to:
Build an array, use json_encode to create the JSON and save it using file_put_contents(). Remebmer to save the whole array and not just the newly added element.
This is not a relative database but might do the trick if you build an intelligent system with cookie's to store an ID that is associated with a user.
Alternative you could use serialize() instead of json;
If you don't mind to use different way of storing data you can use either Google App Engine or mongolab or other cloud based databases

Mysql adapter for Zend_Translate

I'm currently in the planning phase of a rather large project that I'll develop in the Zend Framework. One of the problems I'm facing is that the customers will want to translate not only the content but also the interface. I'm currently using gettext and poedit to manage my language files but this is not an option for the customer as they, for one, wont have FTP access to the site.
Hence, I'm thinking of a mysql back end with an interface in the front end for the customer to manage his own translations of the interface. There is however still no mysql adapater for Zend_Translate.
So, does anybody now of an adapter script for Zend_Translate so it can work with a mysql table? Or any arguments against using mysql and possible other solutions for this problem?
You could solve this problem on different ways:
Extend Zend_Translate_Adapter to create your own. All new adapters are only responsible from getting the translations out from the source. That is, you would need only to fetch the translations from the database. Look at other adapters and see how they are implemented.
Fetch the data from the database and pass it to Zend_Translate_Adapter_Array
Use Zend_Translate_Adapter_Csv or Ini. As there would be more reading the writing on the translations, this solution would cut down the number of queries to the database. When the client adds a new language or changes an existing one, simply write it to a file, not the database.
If you decide to go with the database adapter, maybe you could "tag" somehow the translations, so that on the home page you fetch only the translations for the home page, on the contact page only the translations for the contact page...
HTH!
Default Zend adapters handle caching well, so I'd stick to them, unless you really need database.
Instead storing the translation data in the database, you may directly operate on the translation files (e.g. po templates). This would be the best choice if you just needed to add (append to file) new translation strings.
You may use Zend_Translate's option to log untranslated messages (to file or any log adapter, including database),
and then handle the logs, or even create listener translating the saved strings.
Here's how: http://cloetensbrecht.be/zend_translate_mysql.html