Fix createdb and config filename.

This commit is contained in:
Dominik Picheta 2014-10-14 17:22:02 +01:00
commit 3af3de2ea3
2 changed files with 9 additions and 9 deletions

View file

@ -8,7 +8,7 @@
import strutils, db_sqlite import strutils, db_sqlite
var db = Open(connection="nimforum.db", user="postgres", password="", var db = open(connection="nimforum.db", user="postgres", password="",
database="nimforum") database="nimforum")
const const
@ -16,7 +16,7 @@ const
TPassword = "varchar(32)" TPassword = "varchar(32)"
TEmail = "varchar(30)" TEmail = "varchar(30)"
db.Exec(sql""" db.exec(sql"""
create table if not exists thread( create table if not exists thread(
id integer primary key, id integer primary key,
name varchar(100) not null, name varchar(100) not null,
@ -24,11 +24,11 @@ create table if not exists thread(
modified timestamp not null default (DATETIME('now')) modified timestamp not null default (DATETIME('now'))
);""", []) );""", [])
db.Exec(sql""" db.exec(sql"""
create unique index if not exists ThreadNameIx on thread (name); create unique index if not exists ThreadNameIx on thread (name);
""", []) """, [])
db.Exec(sql(""" db.exec(sql("""
create table if not exists person( create table if not exists person(
id integer primary key, id integer primary key,
name $# not null, name $# not null,
@ -42,14 +42,14 @@ create table if not exists person(
);""" % [TUserName, TPassword, TEmail]), []) );""" % [TUserName, TPassword, TEmail]), [])
# echo "person table already exists" # echo "person table already exists"
db.Exec(sql""" db.exec(sql"""
create unique index if not exists UserNameIx on person (name); create unique index if not exists UserNameIx on person (name);
""", []) """, [])
# ----------------------- Forum ------------------------------------------------ # ----------------------- Forum ------------------------------------------------
if not db.TryExec(sql""" if not db.tryExec(sql"""
create table if not exists post( create table if not exists post(
id integer primary key, id integer primary key,
author integer not null, author integer not null,
@ -66,7 +66,7 @@ create table if not exists post(
# -------------------- Session ------------------------------------------------- # -------------------- Session -------------------------------------------------
if not db.TryExec(sql(""" if not db.tryExec(sql("""
create table if not exists session( create table if not exists session(
id integer primary key, id integer primary key,
ip inet not null, ip inet not null,
@ -77,7 +77,7 @@ create table if not exists session(
);""" % [TPassword]), []): );""" % [TPassword]), []):
echo "session table already exists" echo "session table already exists"
if not db.TryExec(sql""" if not db.tryExec(sql"""
create table if not exists antibot( create table if not exists antibot(
id integer primary key, id integer primary key,
ip inet not null, ip inet not null,
@ -88,6 +88,6 @@ create table if not exists antibot(
#discard stdin.readline() #discard stdin.readline()
Close(db) close(db)