Tutorial by Examples: database

By default, migrations are applied to the same database specified by the db application component. If you want them to be applied to a different database, you may specify the db command-line option like shown below: yii migrate --db=db2
To support a given application, you often create a new role and database to match. The shell commands to run would be these: $ createuser -P blogger Enter password for the new role: ******** Enter it again: ******** $ createdb -O blogger blogger This assumes that pg_hba.conf has been prope...
In the Project.pro file we add : CONFIG += sql in MainWindow.h we write : #include <QMainWindow> #include <QSql> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWid...
In the Project.pro file we add : CONFIG += sql in MainWindow.h we write : #include <QMainWindow> #include <QSql> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget...
In the Project.pro file we add : CONFIG += sql in MainWindow.h we write : #include <QMainWindow> #include <QSql> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget...
Encoding //Create a Base64 Encoded NSString Object NSData *nsdata = [@"iOS Developer Tips encoded in Base64" dataUsingEncoding:NSUTF8StringEncoding]; // Get NSString from NSData object in Base64 NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0]; // Print the B...
pg_dump -Fc -f DATABASE.pgsql DATABASE The -Fc selects the "custom backup format" which gives you more power than raw SQL; see pg_restore for more details. If you want a vanilla SQL file, you can do this instead: pg_dump -f DATABASE.sql DATABASE or even pg_dump DATABASE > DATABA...
Laravel allows user work on multiple database connections. If you need to connect to multiple databases and make them work together, you are beware of the connection setup. You also allow using different types of database in the same application if you required. Default connection In config/dat...
Consider the following example assuming that you have a ';'-delimited CSV to load into your database. 1;max;male;manager;12-7-1985 2;jack;male;executive;21-8-1990 . . . 1000000;marta;female;accountant;15-6-1992 Create the table for insertion. CREATE TABLE `employee` ( `id` INT NOT NULL , ...
To make artisan migrate a fresh database before running tests, use DatabaseMigrations. Also if you want to avoid middleware like Auth, use WithoutMiddleware. <?php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; class ExampleTest ...
Firebase Authentication allows the users of your app to sign-in with social providers or their email+password. But what if you want to store additional information about a user, beyond what Firebase Authentication allows you to specify? Or what if you want to display a list of the users in your app...
A database is created with the following SQL command: CREATE DATABASE myDatabase; This would create an empty database named myDatabase where you can create tables.
Database configuration of a rails project lies in a file config/database.yml. If you create a project using rails new command and don't specify a database engine to be used then rails uses sqlite as the default database. A typical database.yml file with default configuration will look similar to fol...
Rails is shipped by default with ActiveRecord, an ORM (Object Relational Mapping) derived from the pattern with the same name. As an ORM, it is built to handle relational-mapping, and more precisely by handling SQL requests for you, hence the limitation to SQL databases only. However, you can stil...
Suppose we want to count how many counties are there in Texas: var counties = dbContext.States.Single(s => s.Code == "tx").Counties.Count(); The query is correct, but inefficient. States.Single(…) loads a state from the database. Next, Counties loads all 254 counties with all of the...
In PaaS sites such as Heroku, it is usual to receive the database information as a single URL environment variable, instead of several parameters (host, port, user, password...). There is a module, dj_database_url which automatically extracts the DATABASE_URL environment variable to a Python dictio...
Useful for scripting to drop all tables and deletes the database: mysqladmin -u[username] -p[password] drop [database] Use with extreme caution. To DROP database as a SQL Script (you will need DROP privilege on that database): DROP DATABASE database_name or DROP SCHEMA database_name
Mongoid tries to have similar syntax to ActiveRecord when it can. It supports these calls (and many more) User.first #Gets first user from the database User.count #Gets the count of all users from the database User.find(params[:id]) #Returns the user with the id found in params[:id] User.w...
Public Function GetUserFirstName(UserName As String) As String Dim Firstname As String = "" 'Specify the SQL that you want to use including a Parameter Dim SQL As String = "select firstname from users where username=@UserName" 'Provide a Data Sourc...
UCanAccess is a pure Java JDBC driver that allows us to read from and write to Access databases without using ODBC. It uses two other packages, Jackcess and HSQLDB, to perform these tasks. Once it has been set up*, we can work with data in .accdb and .mdb files using code like this: import java.sq...

Page 2 of 10