G'Day,
I want to use the Windows API Postmessage() call from inside a MySQL UDF on MySQL 5.1.51 (XP SP3). I know the UDF (Written in Delphi 2006) is working by setting a bogus result for the UDF.
The syntax of the UDF takes two integer params, one for a window handle and the other for a message number. However a call to PostMessage() from inside my UDF causes an exception in mysqld and the service stops.
Any ideas or pointers? Alternatively if anyone can tell me how I am able to simulate IB Events for MySQL via AnyDAC and Delphi OR an alternate approach to getting a notification when a record has changed in the database then please show me the light.
--Donovan
Your going to run into problems with this approach mainly due to the fact that messaging will only work to the same access level, and within the same session on the same computer. You would be better served by using other methods, such as TCPIP sockets, MailSlots, Memory mapped files, ect.
To best simulate a post message, I would use TCPIP UDP. A good lightweight library that I have used in the past is Synapse. The synapse library from SVN does run quite well against the latest versions of Delphi. The class you will want to use for this is the TUDPBlockSocket.
As an alternative to windows messages or TCP/IP, you might want to consider the named pipes answer to this question on sending information between two Delphi programs and this question on what named pipes are.
--jeroen
While I have had success via the UDF / Windows Pipe route I had another idea leveraging off being able to tap into the information message framework(?) in MySQL. See https://stackoverflow.com/q/3992779/223742
Related
I'm trying to run a GT.M database server in such way that It can be accessed from an application server. I know I can invoke GT.M as a sub-process from other languages. I'm trying to see if I can connect that to a socket/port to be accessed from another server, similar to other database connections(ODBC, MongoDB, Cache).
Are there any utilities? Libraries? to accomplish this. I'm more interested in a mechanistic overview.
The answer is yes, and you have many ways of doing it:
You can run GTCM, part of GT.M. I don't use it, so I don't know much about it, but David Wicksell built it into the Node.js binding to GT.M. More info here: http://tinco.pair.com/bhaskar/gtm/doc/books/ao/UNIX_manual/ch13s02.html and https://github.com/dlwicksell/nodem. Incidentally, you can use Node.js using David's node module.
You can run an M web server: https://github.com/shabiel/M-Web-Server. Look at the documentation folder for examples. Downside is that you have to write some M code (if you don't know M already). This is intended to be used as a web services platform.
--Sam
Have a look at the below link, using this python module you can connect to the DB:
https://github.com/fopina/pyfispip.
Is POST method inherently "secure" and if not, can it be easily made secure or should I use a different protocol entirely?
Please back your statements up with explanation or reference unless they are simply opinion.
The system:
.NET program collecting data with a QR scanner
a web server running CentOS 6
a database on the server to store scans in tables based on QR type.
not all QR types are known now so a new table is created when a new QR type is to be sent.
data needs to get from QR scanner to database as quickly as possible but assume connection is unreliable (think cell phone tethering)
Feel free to comment on my (incorrect?) assumptions about the validity of these other methods I've discounted.
opening a port for MySQL and pushing data in directly - makes IT people panic even if the user has very restricted privileges although I don't see how it's insecure. (also see comments on ssh + MySQL)
using ssh tunnel to insert to MySQL - it's quite conceivable that the database structure will change in the future and I want all the MySQL work done server side so it's easy to modify.
making my own listener on a port on the server and defining my own protocol - seemed daunting at first glance. I know C++/C/Python/PHP so I could do something like this if POST is bad and listener is easy. Don't know where to start or scope of this method.
Example of data packet to be sent. (This is what my .net DLL must receive from the previous person) [QRTypeVersion, HeaderLength, H1, H2, ... DataLength, D1, D2 ..., Comment]
Some good reads:
There are some really good comments about security.
Is either GET or POST more secure than the other?
how to secure POST method without using SSL?
How secure is a HTTP POST?
Hope this helps.
I have a client who wants a control panel for the app I am developing them. The control panel is a Mac OSX application that allows the user to submit files (excel docs and such) to my MySQL database. Those files are then checked by the iOS app I have created for them.
I have no idea how to do this. I have the MySQL database all set up, and I have looked everywhere for a solution. Any help is appreciated.
I wouldn't try to connect to your MySQL database directly from your cell phone. It's a bad design for several reasons. Instead build a API on the same server as the MySQL database. It doesn't matter if you do it in java, php, c# or anything else. You might even find some product or open source project that can do this automatically. I've listed some benefits of doing it this way
It makes testing easier. You can write a test framework against your API that doesn't rely on or is using a phone.
It makes development faster. You don't need to emulate or use a phone to develop and test your table design and queries.
It gives you compatibility. When you need to change your database (and you do) you can create new APIs that the new version of the app uses while and old version still out there can continue to use the old API (that you might have to modify to still provide the same functionallity)
It gives you flexibility. If your user base grows and you might need to have replication for reads or sharded databases you build that into the API instead of into the app which is just a better way to do it.
One option would be to use PHP to handle all the database interaction.
Host the scripts on the server and just have the apps call them and get the scripts to return some sort of parseable response (I'd go for JSON).
I have never found a suitable Object-C based connector for MySQL. At this point I would suggest using a C/C++ connector. There's lots of examples of how to configure the connector for both C and C++. The hard part will be all of the data passed from the MySQL code and the Object-C code will that it will have to be in C types.
EDIT: An Example
How could I connect to Embedded MySQL server (libmysqld.dll library) from Delphi XE3? For now I know only one way – use DevArt MyDAC components (specific TMyEmbConnection), but it is paid what is unacceptable for my task now. Try to use dbExpress, but not successful.
So, I have two questions:
1. Can I use dbExpress or any other components from Delphi XE3?
2. Any third-party components (prefer free)?
Thanks
I've used ZeosLib for that in the past.
Worked quite well actually, although really soon it turned out that it was easier to have a central database.
Several people wanted to use the application, and then they wanted to share their changes, and keep things in sync, etc. Luckily, switching to a mysql server was not much more work than copying the data, and changing the connection component parameters.
Back in the MSSQL 2000 timeline, there was an IIS integration layer that allowed HTTP GET commands to make select statements, and there were other SqlXml niceties that worked (not that fast or well but they worked) out of the box. I gave a chance to expose database stuff fairly quickly.
What is the comparable technology for MSSQL 2008/2012? I saw slashDb (http://www.slashdb.com/) and it seems to do that, but I am trying to understand the other options out there. Just SQL Server crud and sproc access.
Thanks.
Yes, SlashDB does exactly that and more. Full disclosure: I am the founder and CEO.
Once SlashDB is installed you would use its web interface to connect it with your database. Depending which database login and database schema you use for that connection, you will have the tables and views from that schema turned into of URL endpoints.
Those URLs can be followed in the browser but they are also API endpoints in JSON, XML or CSV. It works for reading and writing (you can control that in user configuration).
In addition to that you can define a set of parameterized SQL queries. Each query is given a name and instantly becomes an API endpoint too.
In order to help you getting started easily SlashDB is available on AWS and Azure marketplaces, as a Docker container from DockerHub, pre-built virtual machines or as .rpm and .deb packages for installation directly on Linux.
For more technical info please visit: https://docs.slashdb.com
The nearest equivalent may be SOAP/HTTP endpoints, however Microsoft has deprecated them for various reasons and recommends WCF or ASP.NET instead. Although the simplest way to get a quick CRUD setup is probably to use a framework or ORM that generates it for you, like LINQ to SQL or whatever else suits your needs.