PDO object vs database client program (such as sqldeveloper client side) - database

I have read that to use ex. a relational D.B. we need a D.B server program and a D.B. client program (e.x. SQLdeveloper) which has a GUI for human to write his queries.
When a web backend developer writes a PHP file which communicate with a D.B server program to create a dynamic web page by using a PDO object for example, Is there any need for a Database CLIENT program such as SQLdeveloper or something lighter? or the concept of Client-Server program doesn't have any meaning any more?
I also read that PDO is a driver. Does it mean that it is equivalent to a light D.B client program?
Thanks for helping me to understand it

Related

Is connecting to my SQL server by IP on the server computer different to other computers for testing purposes?

I have a VB.NET application that utilises databases in an SQL server. I am currently testing the application on the same computer the server is hosted on.
I connect to the server through the following connection string...
("Data Source = " & Master.CurrentIP.Text & ",1433;Network Library=DBMSSOCN;Initial Catalog=ExcelDM;User ID=" & Master.CurrentUser.Text & ";Password=" & Master.CurrentPass.Text & ";")
"Master.CurrentIP.Text" refers to my public IP address and not my computer's.
Basically, everything works perfectly when I test the application on this computer. I am wondering if I can use this as a test for other computers joining or not. Should I host my server on something that isn't my computer?
To clarify, remote connections is enabled on the server and port forwarding (port # 1433) is open both incoming and outgoing through windows firewall and my router port forwarding settings. All TCP/IP options are open in the SQL configuration manager etc.
Based on your comments, I'd make the following assumptions:
You aren't holding any sensitive data, so security isn't a major concern
You are going to be running this on a LAN (local area network) and not over the web
If that's the case I'd suggest the following:
You are fine testing on your local machine - the connection will work the same over any protocol on local or remote, and given the small amount of data in a D&D campaign, you probably aren't going to be worried about performance even if your application is very chatty with SQL server
Put your connection information in the application configuration file, this is supported in .NET framework with some helper types like ConfigurationManager where you can access connection strings like so:
Config file:
<connectionStrings>
<add name="MyConnection" providerName="System.Data.SqlClient" connectionString="server=somehostname;database=Dungeons;uid=user;password=password" />
</connectionStrings>
c# code
string connectionString = ConfigurationManager.ConnectionStrings["MyConnection"];
See here for more details:
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files
Since your friends probably don't want to mess with your SQL server and you are probably not joined to a windows domain, I'd say you are fine with putting secrets (user/pass) in the connection string in the configuration file
I'd not bother with what I said about Windows security - basically the users on the client machines would be used as credentials to the SQL database, this would be a bit more of a headache to configure if you aren't all joined to a domain rather than just embedding a SQL user/pass in the config
** Edit: **
Further to conversation, if you are writing an app that clients will be accessing over the web, using a direct SQL connection is not usually the best idea, but it can work if you can manage your clients/IPs.
Generally, opening your SQL server up to the internet is just asking to be attacked - and unless your SQL server is up to date, this can lead to the host machine being compromised.
At best it's an inconvenience, but if you are using that machine for anything other than D&D data, then you probably don't want someone snooping around on it.
In the case that you don't want to change your application architecture
You can whitelist your clients in SQL server/on the firewall. Since it's only friends (let's say 10-20 people?), you can manage their IPs without too much trouble.
This prevents the general internet from being able to access your server.
You could also use a VPN (either software or on your hardware if your router supports it). This also has the effect of putting your clients on your LAN essentially, removing the need for any firewall config apart from the VPN itself.
In the case you are interested in changing your app architecture
You can use a service based approach. This is what is generally used to secure web-based services - .NET framework supports this with WCF (Windows Communication Foundation).
This allows you to define service contracts that your server/client can adhere to.
The communication protocol/method itself is decided via configuration, so you can change what mechanism is used to communicate between client/server after-the-fact without having to change your application code.
This does require you to write a service layer though - you won't be able to directly access SQL from your client, but it could be a useful learning experience, especially if you are interested in doing work like this in the future.
Read about WCF here:
https://learn.microsoft.com/en-us/dotnet/framework/wcf/whats-wcf
There's also the REST based approach which sits down at the HTTP level, .NET framework can support this via ASP.NET web API.
https://dotnet.microsoft.com/apps/aspnet/apis
... so in short, there are a few options

Identify whether server is running MSSQL, IBM DB2, or neither, IE, by using Telnet

I need a way to identify whether a given port at a given address is running an instance of Microsoft SQL Server, IBM DB2 Server, or neither, from Python.
My first thought is that I can use Python's telnet library, telnetlib, like this:
import telnetlib
import socket
def checkDBServerType(address, port):
try:
tn = telnetlib.Telnet(address, port)
except socket.error:
return None
tn.write(<something>)
if <something-else> in tn.read_eager():
return "MSSQL"
else:
return "IBMDB2"
The issue is, I have no idea what to send. The user will also be providing my program with a username, password, and database name, so those are also available if that helps.
Also, this is my first post on ServerFault although I've used StackOverflow regularly and SuperUser sometimes. Is this the proper venue for my question, or would it be more appropriate on StackOverflow? (I can't decide if server admin type people or programmer type people would be more likely to be able to help.)
Since you're just looking for a heuristic, I'd say that merely being able to connect to the default port would be a good first cut. So, for instance, if you can connect to TCP 1433, you can reasonably say that that machine is running a default instance of SQL Server. It's not perfect of course (i.e. you could get false positives or false negatives), but it's pretty good. Only you can answer whether it's good enough for you.
You can't simply "talk" to a database server and expect it to tell you what kind of software it's running; there is no standard common protocol to connect to database servers, and although the query language (SQL) is quite standardized, the underlying connection is based on a protocol which is specific to each database system; these protocols are also generally not text-based, thus you can't simply open a socket to a database server and write something on it; also, they are usually never used directly by client applications: every DBMS provides a set of connection libraries which neatly encapsulate them, so that you don't have to understand how to talk to the database server and can focus on actually querying its data.
Your best bet would be to grab the client connection libraries for SQL Server and DB2 and ask each of them to connect to the remote server; whetever one succeeds first will tell you what kind of server is sitting on the remote end.

Create Program Ala IRC Client, FICS Client

Forgive me if my question sounds silly.
I aspire my program to be database-driver independent. So I plan to make it ala IRC Client or FICS Client.
What kind of server are FICS(Free Internet Chess Server) and IRC Server?
Is it true for the server part, I have to configure a telnet server?
If it is true, is it the only choice?
If I choose telnet server, can I build a client using c# .net winform?
Is a ASP.Net Webservice is a much better solution?
For the client part, I will use c# .net winform.
Please help. Thanks in advance.
After some googling..
I suppose FICS is a telnet server, but clearly a client could connect to the server through telnet connection: http://blog.mekk.waw.pl/archives/7-How-to-write-a-FICS-bot-part-I.html
I've test KpyM server (a telnet server for Win: http://www.kpym.com/2/kpym/index.htm), the server is sufficent to achieve what I plan to do.
I think ASP.Net Webservice is one of the other choices instead of telnet. If someone knows any other, please let me know.
There are many libraries for Telnet for .Net, I've test one of the libraries (http://www.dart.com/telnet-net-code-examples-samples.aspx), so the answer is YES.
I'll leave this one because I don't go in deep for both of the solutions (ASP.Net webservice and telnet)
I wonder why this particular area of IT knowledge doesn't get many responses. In my case is NONE.

server that spawns clients automatically on remote computers

I am developing code for automation testing. Automation is based on client_server.Both client and server code written in C language. I have one server and 3 clients(these clients perform same job) all running on different pcs. I need to manually run first server and then all three clients. These three clients establish connection with server and then automation starts. Now I want to automate starting these clients. What exactly I want to accomplish is to run the server and server by itself starts these three clients(the names/ip.address of these pcs where clients will be running are fixed) automatically by itself. All I have is I know the ip.addresses of pcs,users at those pcs and passwords(login authentication details). How to make this happen. Any suggestions are greatly appreciated. Thanks in advance.....
If all you have is authentication information then you need to look at using ssh for linux and rcmd for windows. Both of these will allow you to access the remote machines and start clients.
Although you should probably consider using Windows services and linux daemons, as they are the standard ways of running these items.

Call a function from my pc via internet

On my PC I have a small program to run SQL Server queries and gets the results back. I don't want to duplicate the DB on the server, I want to call that program on my PC from the server (The server runs Linux OS).
I was thinking of using a web-service to communicate with my PC (using C# maybe), I can attach my PC to a Dynamic DNS (DDNS like No-IP), so I always request the name of the PC not the IP (in case the router restarted and my PC got a new IP).
What do you think, is there a better way to do that?
The fastest solution will probably be to write a web services API written in C#/VB.NET whatever language you prefer. That API could be as simple as executing a remote ad-hoc sql query (rarely recommended) or as complex as a fully blown API. Obviously, security will be important any you may want to create your own SSL certificates and import them to your Linux server (if you're doing this on the cheap) to make sure that your home machine is the one that is reports it is!

Resources