<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Generic SQLite backend (2 and 3)</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PowerDNS manual" HREF="index.html"><LINK REL="UP" TITLE="Backends in detail" HREF="backends-detail.html"><LINK REL="PREVIOUS" TITLE="Oracle backend" HREF="oracle.html"><LINK REL="NEXT" TITLE="DB2 backend" HREF="db2.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PowerDNS manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="oracle.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Appendix A. Backends in detail</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="db2.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="GSQLITE" >A.7. Generic SQLite backend (2 and 3)</A ></H1 ><P > <DIV CLASS="TABLE" ><A NAME="AEN5129" ></A ><P ><B >Table A-7. Generic SQLite backend capabilities</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><TBODY ><TR ><TD >Native</TD ><TD >Yes</TD ></TR ><TR ><TD >Master</TD ><TD >Yes</TD ></TR ><TR ><TD >Slave</TD ><TD >Yes</TD ></TR ><TR ><TD >Superslave</TD ><TD >Yes</TD ></TR ><TR ><TD >Module name</TD ><TD >gsqlite and gsqlite3</TD ></TR ><TR ><TD >Launch name</TD ><TD >gsqlite and gsqlite3</TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > This backend retrieves all data from a SQLite database, which is a RDBMS that's embedded into the application itself, so you won't need to be running a seperate server process. It also reduces overhead, and simplifies installation. At <A HREF="http://www.sqlite.org" TARGET="_top" >http://www.sqlite.org</A > you can find more information about SQLite. </P ><P > As this is a generic backend, built on top of the gSql framework, you can specify all queries as documented in <A HREF="generic-mypgsql-backends.html" >Generic MySQL and PgSQL backends</A >. </P ><P > SQLite exists in two incompatible versions, numbered 2 and 3, and from 2.9.21 onwards, PowerDNS supports both. It is recommended to go with version 3 as it is newer, has better performance and is actively maintained. To use version 3, choose 'launch=gsqlite3'. </P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN5156" >A.7.1. Compiling the SQLite backend</A ></H2 ><P > Before you can begin compiling PowerDNS with the SQLite backend you need to have the SQLite utility and library installed on your system. You can download these from <A HREF="http://www.sqlite.org/download.html" TARGET="_top" >http://www.sqlite.org/download.html</A >, or you can use packages (if your distribution provides those). </P ><P > When you've installed the library you can use: <B CLASS="COMMAND" >./configure --with-modules="gsqlite"</B > or <B CLASS="COMMAND" >./configure --with-modules="gsqlite3"</B > to configure PowerDNS to use the SQLite backend. Compilation can then proceed as usual. </P ><P > SQLite is included in most PowerDNS binary releases. </P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN5164" >A.7.2. Setting up the database</A ></H2 ><P > Before you can use this backend you first have to set it up and fill it with data. The default setup conforms to the following schema: <PRE CLASS="PROGRAMLISTING" > create table domains ( id INTEGER PRIMARY KEY, name VARCHAR(255) NOT NULL, master VARCHAR(128) DEFAULT NULL, last_check INTEGER DEFAULT NULL, type VARCHAR(6) NOT NULL, notified_serial INTEGER DEFAULT NULL, account VARCHAR(40) DEFAULT NULL ); CREATE UNIQUE INDEX name_index ON domains(name); CREATE TABLE records ( id INTEGER PRIMARY KEY, domain_id INTEGER DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(6) DEFAULT NULL, content VARCHAR(255) DEFAULT NULL, ttl INTEGER DEFAULT NULL, prio INTEGER DEFAULT NULL, change_date INTEGER DEFAULT NULL ); CREATE INDEX rec_name_index ON records(name); CREATE INDEX nametype_index ON records(name,type); CREATE INDEX domain_id ON records(domain_id); create table supermasters ( ip VARCHAR(25) NOT NULL, nameserver VARCHAR(255) NOT NULL, account VARCHAR(40) DEFAULT NULL ); </PRE > </P ><P > This schema contains all elements needed for master, slave and superslave operation. </P ><P > After you have created the database you probably want to fill it with data. If you have a BIND zonefile it's as easy as: <B CLASS="COMMAND" >zone2sql --zone=myzonefile --gmysql | sqlite powerdns.sqlite</B >, but you can also use AXFR (or insert data manually). </P ><P > To communicate with a SQLite database, use either the 'sqlite' or 'sqlite3' program, and feed it SQL. </P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN5172" >A.7.3. Using the SQLite backend</A ></H2 ><P > The last thing you need to do is telling PowerDNS to use the SQLite backend. </P ><P > <PRE CLASS="PROGRAMLISTING" > # in pdns.conf launch=gsqlite # or gsqlite3 gsqlite-database=<path to your SQLite database> # or gsqlite3-database </PRE > </P ><P > Then you can start PowerDNS and it should notify you that a connection to the database was made. </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="oracle.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="db2.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Oracle backend</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="backends-detail.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >DB2 backend</TD ></TR ></TABLE ></DIV ></BODY ></HTML >