MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
November
Sun Mon Tue Wed Thu Fri Sat
         
22 23
24 25 26 27 28 29 30
2024
Months
NovDec


Sun, Apr 18, 2021 5:13 pm

DB Browser for SQLite for Microsoft Windows systems

DB Browser for SQLite provides a data base management system (DBMS) for SQLite databases on a variety of operating systems. It is available for Microsoft Windows operating systems—there is even a portable application version that does not have to be installed, but instead can be run from a USB flash drive. The software is also available for macOS—see DB Browser for SQLite on OS X— and Linux systems. SQLIte itself is a relational database management system (RDBMS) available for a variety of operating systems. SQLite is freely available under a public domain license and DB Browser for SQLite is also freely available under a GNU General Public License (GPL). DB Browser for SQLite provides the underlying SQLite software, so you don't need to install SQLite on a system prior to installng DB Browser for SQLite.

[More Info]

[/software/database/sqlite/db_browser] permanent link

Mon, May 14, 2018 11:09 pm

Using local time for date calculations in SQLite

I have an SQLite database that I use to track approval of tasks. Every Monday, I need to generate a count of the number of tasks approved from the prior Tuesday through the Monday on which I'm creating the report. The approval dates are stored in the database as an integer and I enter them in the form 2018-05-14. I use the following SQL command in a Python script to determine the number I've approved in the last week:

sql = 'SELECT COUNT(*) FROM Tasks WHERE Approved >= date(CURRENT_DATE,"-6 day")'

But I noticed that the count didn't always include the tasks I approved on the prior Tuesday. E.g., when I ran the script tonight, May 14, the number reported was 5, yet I expected the result to be 7.

[ More Info ]

[/software/database/sqlite] permanent link

Tue, Nov 28, 2017 11:19 pm

Find entries in one table but not a second table in a database

I have an SQLite database stored on my MacBook Pro laptop that I use to track work requests. The database file is named CRQ.db, since it tracks work done under a Change Request (CRQ). Within that database are several tables two of which are "Equipment" and "Device". For every CRQ that I need to deal with, I store records with the CRQ number in a "CRQ" column and an identifier for each piece of equipment affected by work done under that CRQ in a "Device" column. information on equipment that is affected by the CRQ in the Equipment table. I have another table named "Device" that holds details for each device, including the manufacturer and model number as well as the physical location of the device. The information in the "Description" column in the "Device" table matches the "Device" name in the "Equipment" table. The two tables have the following structure:

Equipment
NameType
CRQText
DeviceText
ProjectText
NotesText
Device
NameType
DescriptionText Unique
ManufacturerText
ModelText
SiteText
BuildingText
RoomText
NotesText

Equipment.Device = Device.Description

[ More Info ]

[/software/database/sql] permanent link

Mon, Nov 13, 2017 11:20 pm

Limit number of records displayed in SQL output

If you have a lot of records in a table in a MySQL, MariaDB, etc. database that are returned when you use the SQL SELECT command to query for matching records, the results may scroll by so that you can't see the initially returned rows. You can limit the number of rows displayed by appending LIMIT n at the end of the command where n is the number of records you want to see at a time. E.g., if I had 100 records in a table named Sales, but wanted to page through them 10 records at a time, I could use SELECT * FROM Sales LIMIT 10; or, if I just wanted to view one field/column in the table, e.g. "Description", I could use SELECT Description FROM Sales LIMIT 10;

[/software/database/sql] permanent link

Fri, Aug 11, 2017 8:42 pm

Using SQL Inner Join

I have an SQLite database stored on my MacBook Pro laptop that I use to track work requests. The database file is named CRQ.db, since it tracks work done under a Change Request (CRQ). Within that database are several tables two of which are "Equipment" and "Device". For every CRQ that I need to deal with, I store information on equipment that is affected by the CRQ. The equipment table has the following structure:

NameType
CRQText
DeviceText
ProjectText
NotesText

The device field holds a unique name assigned to the particular device. A device may be affected by more than one CRQ, so it can, potentially, occur multiple times in the table. A CRQ can affect multiple pieces of equipment.

The device table has the following structure:

NameType
DescriptionText Unique
ManufacturerText
ModelText
SiteText
BuildingText
RoomText
NotesText

[ More Info ]

[/software/database/sql] permanent link

Tue, Jul 18, 2017 10:53 pm

DB Browser for SQLite upgrade to version 3.9.1 on Mac OS X

I upgraded the version of DB Browser for SQLite on my MacBook Pro today to the latest version, 3.9.1v2. Before upgrading, I had version 3.8.0 on the system. When I checked the version from a command line interface, i.e., a Terminal window, using the system_profiler command, I didn't find any references to the program when I searched for "SQLite:", but I saw the version number listed for "sqlitebrowser."

$ system_profiler SPApplicationsDataType | grep -i "SQLite:" -A 2
$ system_profiler SPApplicationsDataType | grep -i "Browser:" -A 2
    sqlitebrowser:

      Version: 3.8.0
$ system_profiler SPApplicationsDataType | grep -i "sqlitebrowser" -A 2
    sqlitebrowser:

      Version: 3.8.0
--
      Location: /Applications/sqlitebrowser.app
      Get Info String: DB Browser for SQLite

$

[ More Info ]

[/software/database/sqlite/db_browser] permanent link

Thu, Jun 29, 2017 10:48 pm

Selecting unique column entries with SQL

If you have a MariaDB, MySQL, SQLite, etc. database that may have more than one occurrence of a value for a particular column in a table, but want to display only unique values, you can fillter out the repeated values using SELECT DISTINCT. E.g., I have a table in a database where each record, aka row, in the table holds two fields: one holds an account id (Acct) and the other a project name. An account can be associated with more than one project and any project may have many account IDs associated with it.

To produce a list of the projects in the table without listing any project more than once and to list the projects in alphabetical order, I can use the SQL statement below:

SELECT DISTINCT Project FROM Acct_Projects ORDER BY Project;

Each record, aka row, in the table holds two fields: one holds an account id (Acct) and the other a project name. For the PHP code I use to query the SQLite database that holds the data to display a list of all the projects in the table, I use the following code:

<?php

$filename   = "/Users/jasmith1/Documents/www/SGRS/SGRS.db";

$query_string = "SELECT DISTINCT Project FROM Acct_Projects ORDER BY Project";

$db_handle  = new SQLite3($filename);

$results     = $db_handle->query($query_string);

echo "<table>\n";
echo "<tr><td><b>Project</b></td></tr>\n";
while ($row = $results->fetchArray()) {
    echo "<tr><td><a href=\"project_acctids.php?project=" . 
          $row['Project']  . "\">" .  $row['Project'] . "</a></td></tr>\n";
}
echo "</table>\n";

?>

I make the project displayed on each row of the HTML table a clickable link that will open another page, project_acctids.php that will, for the project that is clicked on, display all of the account ids associated with that project.

[/software/database/sql] permanent link

Sun, May 28, 2017 10:10 pm

Querying an SQLite Database With PHP

If you wish to query an SQLite database using PHP, you can do so by placing commands similar to those shown below within the code for a webpage:

<?php

$filename = "/Users/jasmith1/Documents/www/test/presidents.db";

$db = new SQLite3($filename);

$results = $db->query('SELECT * FROM Terms');
while ($row = $results->fetchArray()) {
    var_dump($row);
    echo "<br>\n";
}
?>

In the example above, the database location and file name is stored in the variable $filename. The file must be in a location accessible by the webserver and the file permissions must allow access to the file.

[ More Info ]

[/software/database/sqlite] permanent link

Fri, Mar 24, 2017 10:31 pm

Redirecting SQLite output to a file

If you need to redirect the output of SQL commands to a file while using SQLite, you can do so using the .output command. E.g., I have an SQLite database on my MacBook Pro laptop running OS X that contains a table named Equipment. Within that table is a column named Device that is a description for the particular piece of equipment in the table entry. I can view just that field for all records with the SQLite command SELECT Device FROM Equipment. To direct the output of the command to a text file named device.txt, I can use the command .output device.txt. After executing the command to select the Device field from all records, I can then issue the .output command without any arguments to it to return to having the output of commands displayed on the console rather than going to the file.

$ sqlite3 ~/Documents/Work/CRQ/CRQ.db
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> .output device.txt
sqlite> SELECT Device FROM Equipment;
sqlite> .output
sqlite>

[/software/database/sqlite] permanent link

Wed, Feb 08, 2017 8:41 pm

Running SQL commands from a text file using sqlite3

Every week I need to determine the number of tasks I reviewed and approved in the prior week. I track the tasks in a database on my MacBook Pro laptop using the SQLite utility that is part of the OS X operating system - see Using SQLite. I have a database named "CRQ" that contains a table named "Tasks". The schema for the table is shown below; approval dates are stored as integers; SQLite does not have a storage class specifically for dates, instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values1.

$ sqlite3 ~/Documents/Work/CRQ/CRQ.db
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> .schema Tasks
CREATE TABLE "Tasks" (
`CRQ`	TEXT NOT NULL,
`Task`	TEXT NOT NULL,
`URL`	TEXT,
`Received`	INTEGER,
`Reviewed`	INTEGER,
`Approved`	INTEGER,
`Notes`	TEXT,
`Summary`	TEXT
);
sqlite> .exit
$

I can open the database and manually type the command to count the records with an approval date on or after a date I specify using an SQL command like the one below:

$ sqlite3 ~/Documents/Work/CRQ/CRQ.db
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> SELECT COUNT(*) FROM Tasks WHERE Approved >= '2017-02-01';
11
sqlite>

[ More Info ]

[/software/database/sqlite] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo