communication between raspberryPi, gsm module and database - python

i'am just learning about raspberryPi. how can i communicate raspberryPi with database, so that can raspberryPi send message/sms using gsm module?? and how the Raspberry Pi read databases mysql from different tables that could be sent in a single sentence using gsm?
I hope any suggestion given to me from friends in here
Thanks

Nice first question adew!
To improve the next future question you make please read: https://stackoverflow.com/help/how-to-ask
I will take the time to try answer your question, because I suspect that there is more people out there with the same ideas as you.
To start with
GSM module communication:
This question has many different answers and the answer depends on what hardware you will use. There is no standard in this area.
To give you some options;
https://www.sparkfun.com/products/9533
https://www.adafruit.com/products/2636
Sparkfun will provide you with a detailed datashet & Adafruit even has a detailed tutorial. The drawback with the Adafruit tutorial is that it assumes that you are using a arduino (Not a big problem)
Both of the above modules are capable of UART communication, something you easily can access with a RaspberryPI and
http://pyserial.readthedocs.io/en/latest/pyserial_api.html
https://github.com/WiringPi/WiringPi-Python
Personally I have used WiringPI before and it is easy to start with and has a bunch of active maintainers on IRC.
To wrap up the GSM-part. Consult the manual for that particular device you are going to use. That is the only way you will know what to send and what you will receive from the module.
Database querys:
Are you using a existing database or are you going to create your own from scratch?
Even that part of the question is to broad.
If you are going to make a new database just for this kind of application I might suggest using
https://www.sqlalchemy.org/
It will give you a nice little ORM tool. It will make it easy for you to insert and fetch data that probably matches how you want to work with the data.
If the database is a existing MySQL database
https://dev.mysql.com/doc/connector-python/en/connector-python-examples.html
Well again, consult the manual.
To wrap this up.
This was a very lengthy post, that gave you almost nothing about almost everything. This is why people down-votes a questions like the one you made. Most people dont have the time to give this kind of answers.
I suspect that the next question you make will be related to any of the above topics.
Try to be precise
Give a piece of code that exposes the problem you have
One problem at a time
Happy hacking & have a look at https://raspberrypi.stackexchange.com/ !
//David Bern

Related

How steamkit work?

Currently, i want to implement a trading system for steam games (with python).
So, i searched github, but sadly, there are only
https://github.com/Jessecar96/SteamBot
https://github.com/Jessecar96/SteamKit2
Yeah, they works good. But they are C# -- don't tell me python can't do this :).
So, i want to start with the steamkit part. I thought it's not difficult(maybe just some web-apis), but when i kinda review the code of SteamKit2, i find it seems use TcpConnection to Steam Network, don't know how they get the protocol.
Does anyone has any idea about this, i think about use python load steamkit2.dll, but im really noob with C#
You don't want to use the SteamKit2 port on that repository. It is a branch (and an out dated one at that) of the official SteamKit2 repository. It also looks like they are attempting to get rid of the branch based on this issue discussion.
To answer your question, there is a port of SteamKit to Python. It is called PySteamKit and is written by one of the contributors to SteamKit2.
Unfortunately, there doesn't seem to be much documentation in the Wiki of either the official SteamKit or the Python port on how to use the package. You may have to look at the Samples provided by SteamKit which are in C#.

Using python to control a phone with bluetooth

I would like to know if there are any API's for python to programmatically control a phone, like starting and ending calls, but also to record conversations.
I would also like to use the Headphones and Mic of the computer to talk over the phone.
Any info would be great, I tried googling for something, but nothing useful came up.
Be careful when using PyBluez! The results will actually depend on the BT-USB dongle you are using. Depending on the hardware(the BT chip in there), PyBluez will use one or another BT stack - for example there was one from WIDCOMM. Results will vary, as PyBluez is actually wrapping around those stacks - all of which are far from complete.
So, when you have a working project, be sure to know what actual BT stack you were using :)
For Python audio stuff, you could try this.
PyBluez is an effort to create python wrappers around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications.
Unfortunately I've not found a page dedicated to its features, but it could be a good starting point, whether everything you need is in its feature set, or if you could build your application upon it by extending it.
http://code.google.com/p/pybluez/

How would one go about developing a curses-based UI?

I'm planning to develop a GUI application that uses curses. The idea is to provide an extra interface for a web interface, so that everything on the web site could also be done via the UI.
Basically, it should be platform independent: the user would have to SSH to the server after which the UI would automatically take over.
First of all, is this doable? As far as I understand, it would be platform independent as long as the end-user had the proper terminal software installed. Correct me, if I'm wrong.
I was planning to use Python for this, as it is the language I'm the most proficient in. Python comes with the ncurses library and Urwid, which I've been told, is quite good.
After having a quick test with Urwid, I had some problems. The thing is, I'm quite worried that I won't find answers to the problems that I will encounter down the road because apparently curses UI-s aren't all the rage nowadays. Documentation and examples are thus quite scarce.
In conclusion, should really I embark on this and quit my whining or drop the idea altogether? Any other suggestions?
It's certainly possible, and curses-based applications are still written regularly (e.g. PuDB is only 14 months old) although maybe not very often.
Did you try asking questions on the Urwid mailing list and/or IRC channel?
oh my, wouldn't this be a dream!
i've seen a couple of things out there to varying degrees of success.
Morticious Thrind: http://thrind.xamai.ca/
future death toll: http://f-dt.com/?wptheme=wp-cli
wordpress yadda yadda, this could be as simple as a 960/blueprint CSS, prototype.js, and a oneliner:
//TODO: Implement useful functionality && unit tests && documentation
//TODO: read
try { eval($F(x)); } catch (e) { panic(); }
BUT! this type of thing is pretty radical. i mean- ANYTHING can happen on the canvas of a web-browser these days, but any terminal emulator or lynx serves this purpose with flare.
also be sure to check out: https://stackoverflow.com/questions/472644/javascript-collection-of-one-line-useful-functions
the real question is what sort of software you plan on ncursing (sic,pun,etc.)-- it probably already has some rather useful command-line interfaces (sh).
It can be done but it's a struggle. I would recommend improving the web interface. You can use JavaScript to add keyboard shortcuts, for example, which can be very helpful for a faster workflow (see Gmail's interface, for example).

Rookie Python-questions

Is it possible to make python run on your homepage? I know, this is a really stupid question but please don't pick on me for my stupidity :)
If it is possible, how? Do you have to upload/install the executing part of Python to you website using FTP? or...?
Edit: Just found out my provider does not support python and that shell access is completely restricted. Problem solved :)
Everything depends on the hosting provider you use for your homepage -- do they offer Python among their services, and, if so, what version, and how do you write server-side scripts to use it (is it CGI-only, or...?) -- if not, or the version / deployment options disappoint, what do they allow in terms of giving you shell access and running long-time processes?
It's impossible for us to judge any of these aspects, because every single one of them depends on your hosting provider, and absolutely none of them depends on Python itself!-)
Yes, you can. I don't know exactly how but I know it is possible. Mabye look into this website:
https://trinket.io/
This website lets you do this. I sent them a message to see how they do it so I will update this to let you know after they respond.
Python is a scripting language, though it is used gracefully for building back end web applications.

Python IRC client: write from scratch or write plugin for existing framework?

For our company I'd like to have a Python based IRC bot which checks whether the websites of our clients are still up and running. More specific: I want to list a number of URL which should be visited every, say, 15 minutes. If it fails, the URL should be checked again after 5 minutes. If retrieving the URL still doesn't result in an HTTP status code 200, it should echo the failing URL in the channel so we can investigate it.
I've written a plugin for Supybot some time ago that basically does some of the above in a crude but effective way. If I want to expand the functionality of the current code to the above 'specs' I need to do some major refactoring; basically it would mean starting from scratch.
Which raises the question: should I write a better plugin for Supybot, matching the new requirements, or go for something else altogether? Should I start from scratch (learning the most, implementing the relevant RFCs myself, spending more time than planned) or is there a suitable framework which handles the basic IRC stuff?
I vote for a completely new plugin for Supybot. Learn more ;)
If you won't do so much, try python irclib. It's a (still maintained) python lib for IRC.
Twisted may also be ok, but it's a little but too much...
To me it sounds like a case of your application wanting to talk IRC, and my gut reaction would be to use Twisted, which has IRC clients. This may or may not be the right solution for you, but at least it's worth investigating.
I finally decided to create use Twisted for my bot. As to the why:
Supybot already has a lot of functionality. And that can be a good thing: just create a simple plugin, hook it up and start using the bot. The downside is that you may not like some of the functionality already provided for. As an example: I didn't like the fact that it responded to everything (Error: "foo" is not a valid command.). I'm sure it can be turned off somehow somewhere, but these kind of small things bothered me.
The Python IRC client library on the other hand felt a little too bare bones. Especially since I needed threading to have the bot check a whether a number of websites are still alive while remaining responsive in the channel.
If the irclib felt like too low level, writing a bot from scratch would certainly be. While I definitely wanted to learn something, I also wanted to focus on the actual functionality of the bot, without being bothered too much by the 'basic' stuff (e.g. I don't necessarily want to write the code to identify the bot, I like to just have some configuration setting to store the nickname and password and handle this for me.)
Twisted has a nice example of a logging bot which can be used as a starting point. Furthermore: in the future it should not be too hard to write a small webserver (using Twisted obviously) to display the output of the bot.
Tip: besides the Twisted documentation you can also take a look at the October 2008 issue of Python Magazine for the article "A Twisted Logging Server" by Doug Farrell.
Thanks to the ones who answered the question. You set me on the right track. :)
Writing a simple IRC bot isn't that hard. I have a template I keep using for my bots, which range from SVN bots to voting-status bots to bots which check connections to certain IPs and change the channel's topic according to the result.
I can share the source if you'd like, though there's nothing like writing your own :)
irc3 is a plugable irc client library based on asyncio and venusian https://irc3.readthedocs.org/

Categories

Resources