Packaging database into application seamlessly for users - database

I want to create a desktop application that uses a relational database (such as postgres - let's say my best case scenario is to use postgres in this application).
I want users to be unaware of the database. Currently, I had to install postgres into my local computer and have my application communicate with that.
I am using Go.
How can I avoid this?

You're looking for an embedded database.
This isn't an ideal job for PostgreSQL, but you can use it that way with a bit of care.
Please don't bundle the installer and run it unattended. Users who later go to install PostgreSQL will be very confused when they see it's already on their computer but they don't know why, who installed it, or what the password is.
Instead initdb a new datadir inside your app's %APPDATA% or (for multiuser shared) in %PROGRAMDATA%. Set a custom port (don't use the default 5432). Create a new service with pg_ctl register, running as NETWORKSERVICE, or just start/stop on demand with pg_ctl. That way you won't get in the way of any existing PostgreSQL installs or new ones and have a private PostgreSQL just for your app.
Please offer users the option of instead supplying a connection string for an existing PostgreSQL though. It's a pain if apps insist on using their own embedded copy when you don't want them to.
Often it's better to look at using SQLite, H2, Derby, Firebird, or one of the other embedded DBs, though.

Short version, you really can't, your best bet is to use SQLite or similar.
Long version, well, if you really really want to, you can create multiple unattended installers for your database that targets each platform you want, embed it into your application and install it on the first run.
Now that is just ugly and most users (myself included) would outright never use it.
You can always mention that your software depends on X and Y and provide information about how to manually install the dependencies.

Related

Version control for SqlServer

I'm working on a legacy SqlServer database with no version control. I've tried importing it into a VS 2017 database project, but it takes more than an hour to load ("your project will be ready after 1200000 operations are completed"), and usually crashes out in less time than it took to load.
Does anyone have any suggestions for a version control system I can try that will cope with real-life databases?
Baseline your Database and call this Version 0.1.0
As you need to make changes to it, like add columns, data etc. Script this and add this to the source control of your choice. Call this file something like:
Version-0.1.1.sql
As you make more and more changes the amounts of files will be added to.
Version-0.1.2.sql
Version-0.1.3.sql
Version-0.1.4.sql
Of course you will test these before you deploy to live. As you are working with what is a legacy system I would probably shy away from investment in expensive tools for what is a legacy system in the first place.
To bring a database to a particular version you would run the scripts in the order. Obviously in each script you have failover etc that handles anything that may go wrong within the scripts.
It is a manual process but the best points are it's cheap, easily to understand, does not require much expense and it's a methodical system to manage change.
Note: Obviously deploy scripts to a UAT version before directly on Live.
I have had a lot of success using flyway with both sql server and postgres. It allows you to create numbered versions as betelgeuce described in his answer, but also offers additional protection of ensuring your earlier versions haven't been changed before deploying any new changes

How to transfer live WordPress site to Wamp?

I've got a wordpress site that I have been using for a year now and it is hosted with HostGator. I have got a few tests i would like to run on the site, but I would like to test it offline using wamp first before making it LIVE.
The problem is previously I was always making changes to the LIVE site, usually at hours when I get little to no traffic. However, that has changed now and I do get traffic most hours through out a 24hr day.
So my problem is:
How do i download my existing website to laptop (wamp) and make those changes with new theme? (total newbie, sorry!)
I use Windows 7, so not sure what I need to be doing to get the site working like a live site offline.
Once I have implemented the new changes, what is the best way to upload the updated site back to the HostGator server without having any downtime or errors for site visitors?
Is there anything else I need to install or do inorder for this to work? I hope you can give me as much information as possible or any links to any guides or articles that explain how to do this.
Thanks so much for any help you can offer!!!
If you're using Hostgator, the process is simple:
Install XAMPP or WAMPP on your computer;
Go to your cPanel, backup and download your website;
Extract the backup to your computer, specially the homedir and the sql;
Go to your local environment, access http://localhost/phpmyadmin
Create a new database, doesn't matter the name but for the example let's call it "database";
Inside that database, import the one taken from the backup;
create a new folder inside your htdocs with the name of your website, "example.com";
Extract the content of the homedir there;
edit wp-config with the following data:
Host: 'localhost'
Username: 'root'
Password: blank
access http://localhost/example.com
You can check a good tutorial about the subject here.
About putting the site live, I recommend you to use a GIT repository, however it's understandable that might be a little complicated and perhaps too much work for what you're trying to achieve.
Try to move your files directly from your local to live environment using Filezilla or WinSCP, the drag and drop should replace the files live and the downtime should be minimal.
Instead of WAMP, you can always use VirtualBox to install CentOS or Ubuntu/Debian.
You can go one further and install either CentminMod to automate creating a LAMP, or a full panel like ISPConfig or Virtualmin.
That take care of create the environment.
Create a new account on the LAMP, using the same domain name.
You can FTP with Windows to get the files, but networking Windows and Linux is a pain. The better option is to use the command line (CLI) in the Linux VM to ftp the files from Hostgator to the VM. This guide will help with that process: http://www.tldp.org/HOWTO/FTP-3.html
Then your only concern is the MySQL database. And for this, you have several options.
For me, the easiest is to buy (or try!) SQLyog on Windows, and then copy the database from the Hostgator source to the localhost destination. Some mild networking is needed for Windows to see the Linux VM, but nothing as complex as file sharing (the FTP issue). SQLyog is far quicker than backing up the database, then restoring it -- especially since you can run into memory issues doing it this way. It fully depends on the size of the database.
The cheap/free backup>restore method is to use phpMyAdmin.
WordPress also has plugins, of varying cost, but you still have the possible backup>restore memory issue there as well.
When done, just copy it the other way, again using SQLyog and CLI ftp. You'll still have some downtime, but it will hopefully be minimal.
As a newbie, this probably seems like rocket science, but at least it gives you a good place to start. Welcome to the world of locally dev'ing sites!

Multiple-domain security with SSDT .sqlproj projects?

I'm doing a small pilot project trying to implement Sql Server Data Tools sqlproj projects in order to better bring our databases under source control. In my organization, we have separate no-trust domains for test environments of various purposes, so these domains of course have their own isolated active directory accounts.
The documentation is still somewhat sparse and I don't really know where to go for more information on this toolset, especially considering the extraordinary amount of churn in Visual Studio's history of database assets.
So far, the only idea I've really had would be to make separate sqlproj projects specifically for the security objects each separate domain, separate from the other schema objects. My hope is that somehow I can tie my actual database schema to those at deploy time and also to somehow switch which security project I'm using in the build. I have no idea if that's feasible though.
Has anyone that uses Visual Studio sqlproj projects had to deal with this? Is there a best practice for this kind of thing?
If you have different settings for each environment then the easiest is to either leave them out and not delete them when you deploy or to have a post deploy script that sets them up manually.
Normally for handling different configurations I would suggest using sql cmd variables (on the properties of the project there is a page for setting these up) but when you create a login you cannot use a variable to create it so that falls over!
There is an example on how to setup a post deploy wrapper for just this case:
http://schottsql.blogspot.co.uk/2013/05/ssdt-setting-different-permissions-per.html
Good luck with ssdt, there are some strange quirks but it enables so much!

Deploy IPad application with its database

can any one tell me if I could deploy an IPad application with its pre-initialized database?
I'm using IOS developer Enterprise program account
Include the database as a resource in the bundle and clone it into the users document folder at launch.
The reason to clone is that you dont get write privileges on bundle resources.
Alternatively since this is not code you could download it from the corporate server at launch but since you are asking this question you probably dont want to do that.
Yes you can do it.
You can use sqlite in your ios application. You can create locally an prefilled sqlite database, and at this one to your xcode project.
In your project you must copy the sqlitedatabase from your resourcesfolder to the app's documents folder.
Depends on who's the developer of the app. If it's you, you can easily do so. Else, you won't be able (since apps are stored in a security sandbox).
If you really need to, you could consider jailbreaking them (you won't need a Enterprise Program though) so you can enter those sandboxes and add custom property lists to them.

Syncing a site with a local machine?

I do my web development and testing on my laptop running an installation of xampp - I upload things to my host, but I always go through cpanel's file manager to do it. I realize that there's definitely a better way to go about it, but I need to be pointed in the right direction to do so, also other tips on how to manage stuff would be appreciated.
FTP - can I keep my site's stuff synched to a local directory on htdocs so I can keep my site backed up on my computer yet update the site with whatever changes I make locally? Can anyone recommend a good client (preferably free) that I can use to do this?
Database stuff - how do I backup / sync databases in the same way? Ideally I'd like to do the same thing as with my files. Merge / upload whatever I've developed with a click or two. Is this possible? Is this wise?
Any help and advice would be appreciated. :)
I do my development in Eclipse which allows me to combine development and sync via FTP in one environment. It will also tell you if a file changed on the server and allow you to decide whether to override it or not. You can also disable the syncing of certain types of files with pattern matching and use other technologies like WebDAV or SSH to sync (if supported by your host of course).

Resources