Pinax TemplateSyntaxError - pinax

i ran into this errors while trying to modify pinax database model
i am using eclipse pydev
i have this error on the pydev
Exception Type: TemplateSyntaxError at /
Exception Value: Caught an exception while rendering: (1146, "Table 'test1.announcements_announcement' doesn't exist")
please how do i correct this
UPDATE: i asked this question and left unresolved some months back and you what ran into the bug again this week and typed the error message in google hit the page with the question and unanswered so i think i have to answer it and hope it help someone in the future have the same problem.
some the problem is that the sqlite path is out of place so django or this case pinax can not find it so to resolve that change the absolute path to sqlite like it
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = os.path.join(PROJECT_ROOT,'dev.db' ) # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
i hope that help

chnge the sqlite3 path like this
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. DATABASE_NAME = os.path.join(PROJECT_ROOT,'dev.db' ) # Or path to database file if using sqlite3. DATABASE_USER = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.

If your database model is missing a column, run
python manage.py syncdb
from the command line. This ensures that your models match the underlying database representation.

Related

Symfony 3.4 LTS, PostgreSQL 10, DoctrineDBAL could not find driver

I use MAMP server with PHP 7.1.5; Symfony Framework 3.4.2, PostgreSQL 10 for a new project. I also use PostGIS to store space data with geometry data type in PostgreSQL. Therefore I installed and used: "jsor/doctrine-postgis": "^1.5"
Following is part of my composer.json:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"jsor/doctrine-postgis": "^1.5",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
The parameters.yml:
server_ver: 10.0
database_driver: pdo_pgsql
database_host: localhost
database_port: 5432
database_name: qtqg
database_path: ~
database_user: postgres
database_password: admin
The config.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
mapping_types:
_text: string
server_version: %server_ver%
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
path: %database_path%
user: %database_user%
password: %database_password%
persistent: true
charset: UTF8
logging: %kernel.debug%
profiling: %kernel.debug%
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
types:
geography:
class: 'Jsor\Doctrine\PostGIS\Types\GeographyType'
commented: false
geometry:
class: 'Jsor\Doctrine\PostGIS\Types\GeometryType'
commented: false
raster:
class: 'Jsor\Doctrine\PostGIS\Types\RasterType'
commented: false
Everything work well, I can use cmd to generate Entity:
php bin/console doctrine:mapping:import --force AppBundle annotation
And after that generate CRUD:
php bin/console generate:doctrine:crud AppBundleMonitoringAdminBundle:coquan -n --format=annotation --with-write
The Running PHP is PHP 7.1.5 and I also checked php.ini file in C:\Windows and loaded php.ini in MAMP server. php -m command shows:
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
I don't think any problem with data driver because it can connect and generate Entities, CRUD....
But after generate CRUD and try to access the controller to list all item in one Entity, I got the Error:
An exception occurred in driver: could not find driver
One of the error line is:
AbstractPostgreSQLDriver->convertException('An exception occurred in driver: could not find driver', object(PDOException)) in vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php (line 176)
I tried many way including changing mamp to xamp, wamp server, all recommendation about how to config dbal... but the error is still there
Could anyone help me!
the problem is with PostgreSQL 10
Inside vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php line line 292 change
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
For
$version = floatval($this->_conn->getWrappedConnection()->getServerVersion());
if ($version >= 10) {
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = \'public\' AND sequencename = '.$this->_conn->quote($sequenceName));
}
else
{
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
}
I was have the same issue with postgres 9.6.4 with WAMP on windows 10
phpinfo() would display pdo_pgsql as loaded, and it worked fine in another PHP application. php -m from the gitbash would not show pdo_pgsql
In the end, I had to edit the php.ini that was loaded and uncomment these 2 lines
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
restart apache and now it works!!!!

perl configuration file which contains variables?

I want to create a perl configuration file. I want a file format which has variables. So something like this:
DefaultDirectory = /var/myProgram/
OutputDirectory = $DefaultDirectory/output
InputDirectory = $DefaultDirectory/input
This seems simple, but I'm not sure what is available with perl. The perl ini options I see don't appear to support it. I looked into YAML, but it seems almost overkill.
Can anyone suggest a good file format and CPAN module that supports it which can support simple variables? I'm stuck with perl 5.5 so hopefully an older module.
Try Config::General.
test.cfg
# Simple variables
DefaultDirectory = /var/myProgram
OutputDirectory = $DefaultDirectory/output
InputDirectory = $DefaultDirectory/input
# Blocks of related variables
<host_dev>
host = devsite.example.com
user = devuser
password = ComeOnIn
</host_dev>
<host_prod>
host = prodsite.example.com
user = produser
password = LockedDown
</host_prod>
test.pl
#!/usr/bin/perl
use strict;
use warnings;
use Config::General;
my $conf = Config::General->new(
-ConfigFile => 'test.cfg',
-InterPolateVars => 1
);
my %config = $conf->getall;
print <<HERE;
Default directory: $config{'DefaultDirectory'}
Output directory: $config{'OutputDirectory'}
Input directory: $config{'InputDirectory'}
Development host: $config{'host_dev'}{'host'}
Development password: $config{'host_dev'}{'password'}
Production host: $config{'host_prod'}{'host'}
Production password: $config{'host_prod'}{'password'}
HERE
Output:
Default directory: /var/myProgram
Output directory: /var/myProgram/output
Input directory: /var/myProgram/input
Development host: devsite.example.com
Development password: ComeOnIn
Production host: prodsite.example.com
Production password: LockedDown
Have you considered just writing your own perl module that contains config?
Something like (MyConfig.pm):
package MyConfig;
our $DefaultDirectory = '/path/to/somewhere';
our $setting_for_something = 5;
1;
You can then import that with use MyConfig;. You may need to set use lib or FindBin to find the module first though (depends on where you invoke the script - use will search cwd).
But really - perl 5.5? That's .... well worth updating, given that's the version from 2004. I do hope you don't run too much stuff on 10 year old software - the world has changed A LOT in the intervening time. (And so has Perl)

Change configuration parameters from command-line or programatically

How can I change settings in pg_hba.conf and postgresql.conf either from the command-line or programatically (especially from fabric or fabtools)?
I already found set_config, but that does not seem to work for parameters which require a server restart. The parameters to change are listen_addresses in postgresql.conf and a new line in pg_hba.conf, so connections from our sub-network will be accepted.
This is needed to write deployment scripts using fabric. It is not an option to copy template-files which then override the existing *.conf files, because the database server might be shared with other applications which bring their own configuration parameters. Thus, the existing configuration must be altered, not replaced.
Here is the currently working solution, incorporating the hint from a_horse_with_no_name. I paste a snippet from our fabfile.py (it uses require from fabtools, and it runs against Ubuntu):
db_name = env.variables['DB_NAME']
db_user = env.variables['DB_USER']
db_pass = env.variables['DB_PASSWORD']
# Require a PostgreSQL server.
require.postgres.server(version="9.4")
require.postgres.user(db_user, db_pass)
require.postgres.database(db_name, db_user)
# Listen on all addresses - use firewall to block inadequate access.
sudo(''' psql -c "ALTER SYSTEM SET listen_addresses='*';" ''', user='postgres')
# Download the remote pg_hba.conf to a temp file
tmp = tempfile.NamedTemporaryFile()
with open(tmp.name, "w") as f:
get("/etc/postgresql/9.4/main/pg_hba.conf", f, use_sudo=True)
# Define the necessary line in pg_hba.conf.
hba_line = "host all all {DB_ACCEPT_IP}/0 md5".format(**env.variables)
# Search the hba_line in the existing pg_hba.conf
with open(tmp.name, "ra") as f:
for line in f:
if hba_line in line:
found = True
break
else:
found = False
# If it does not exist, append it and upload the modified pg_hba.conf to the remote machine.
if not found:
with open(tmp.name, "a") as f:
f.write(hba_line)
put(f.name, "/etc/postgresql/9.4/main/pg_hba.conf", use_sudo=True)
# Restart the postgresql service, so the changes take effect.
sudo("service postgresql restart")
The aspect I don't like with this solution is that if I change DB_ACCEPT_IP, this will just append a new line and not remove the old one. I am sure a cleaner solution is possible.

Error while installing Moodle 29

I have place moodle files: C:\xampp\htdocs\moodle, E:\moodledata and in mysql created database "moodle".I m getting this error message on the webpage when opening moodle
"Config table does not contain version, can not continue, sorry.
More information about this error
It is usually not possible to recover from errors triggered during installation, you may need to create a new database or use a different database prefix if you want to retry the installation."
Setting in config.php
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'root';
$CFG->dbpass = '';
$CFG->prefix = 'lms_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
);
$CFG->wwwroot = 'http://'.$_SERVER['HTTP_HOST'].'/moodle';
$CFG->dataroot = 'E:\\moodledata';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(dirname(__FILE__) . '/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
It looks like it got interrupted during install and now the database is incomplete. You can try two things: insert the missing version number into the config table, for example by using phpMyAdmin, or delete the database, create a new one and try to install again.
To insert the version number:
open the file version.php to find the version number.
in your database manager, go to the table mdl_config
insert a new record with the values: name='version' and value='the version number you looked up in the version.php file'
this can happen if the install process is not perfect.
You haven't told us the version or anything about the 'local server'
so we can not see the specifics of your problem.
check the release notes for the version you are using and make sure 100% that your server meets the requirements.

unable to connect to multiple database using Dancer::Plugin::Database

I am using Dancer::Plugin::Database to connect with database from my dancer application. It works fine for single connection. When i tried for multiple connection i got error. How can i add multiple connection.
I added the following code in my config.yml file:
plugins:
Database:
connections:
one:
driver: 'mysql'
database: 'employeedetails'
host: 'localhost'
port: 3306
username: 'remya'
password: 'remy#'
connection_check_threshold: 10
dbi_params:
RaiseError: 1
AutoCommit: 1
on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ]
log_queries: 1
two:
driver: 'mysql'
database: 'employeetree'
host: 'localhost'
port: 3306
username: 'remya'
password: 'remy#'
connection_check_threshold: 10
dbi_params:
RaiseError: 1
AutoCommit: 1
on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ]
log_queries: 1
Then i tried to connect with database using the following code :
my $dbh=database('one');
my $sth=$dbh->prepare("select * from table_name where id=?");
$sth->execute(1);
I got compilation error, "Unable to parse Configuration file"
Please suggest a solution.
Thanks in advance
YAML requires consistent indentation for the keys of a hash. Remove four spaces from before "two:" and it should parse.
Update: I see there's been some editing of indentation; going back to the original question produces a parsing error in a different place and shows a mixture of tabs and spaces being used; try to consistently use only tabs or only spaces. You can test your file and find what line is producing the first error like so:
$ perl -we'use YAML::Syck; LoadFile "config.yml"'
Syck parser (line 19, column 16): syntax error at -e line 1, <> chunk 1.
Also make sure that your keys are all ending up in the right hash (the mixture of tabs and spaces seems to allow this coming out wrong but still parsing successfully) with:
perl -we'use YAML::Syck; use Data::Dumper; $Data::Dumper::Sortkeys=$Data::Dumper::Useqq=1; print Dumper LoadFile "config.yml"'