django.contrib.postgres.fields with SQLite - django-models

In Django 1.8, what happens if I try to run unit tests against a SQLite DB when the model has fields from django.contrib.postgres.fields?

It won't work! The import you mention requires psycopg2 driver.

Related

SQL Server Windows Authentication and Hibernate

Trying to connect, using Hibernate 4.3, to SQL Server with Windows Authentication, i'm getting a:
"No Persistence provider for EntityManager named instanceTest"
I have loaded the sqljdbc_auth.dll library and im using this url:
jdbc:sqlserver://localhost:1433;databaseName=WIN_AUTHDB;integratedSecurity=true
The parameters which i am using to create the entity manager factory are:
properties.put("background-validation", "true");
properties.put("hibernate.c3p0.idle_test_period", "3600");
properties.put("hibernate.hbm2ddl.auto", "update");
properties.put("hibernate.max_fetch_depth", "3");
properties.put("hibernate.connection.driver_class", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
properties.put("hibernate.connection.url","jdbc:sqlserver://localhost:1433;databaseName=WIN_AUTHDB;integratedSecurity=true");
Im missing something? Maybe is the dll not loaded? The error is thrown at this line:
Persistence.createEntityManagerFactory("instanceTest", initProperties(properties));
The database is correctly configured, i have connected through Windows Authentication with the SQL Server Management. Also, in a previous test, i achieved to create a database using the driver without hibernate.
Thanks in advance.
Along those, add the below property
properties.put("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
Resolved!
Much more simple than I thought. When I was compiling the maven project, i was unintentionally deleting the persistence.xml file. Thats the reason because it never found the persistence provider at the war.

Metasploit msfrpcd with database

I have a problem, I want to run Metasploit framework as a service, but it can not connect database if use "msfrpcd" tool. If I use msfconsole and "load msgrpc" is ok. So can you help me connect to the database when I use the "msfrpcd" tool. Thanks for your supports.
Try starting the postgres service.
Try running these commnands
service postgres start
msfdb init
msfconsole
This should do the trick.

can not PDO nuodb

I want to connect nuonb with yii framework. After i configed from this guide (configuring database connection in Yii framework)
I cannot connect to database.
So I look at another page that config nuodb with php Framework.
http://www.nuodb.com/techblog/2013/06/20/using-nuodb-from-the-php-zend-framework/
I configed and test in command line I think it work case after i use this command
php -i | grep PDO
The Result is
----------------------------------------
PDO support => enabled
PDO drivers => mysql
PDO Driver for MySQL => enabled
But when I use function to test PDO in php with function phpInfo(), It can't find nuodb PDO ( PDO is no value).
Please help me fix this problem.
Remark. My server is Aws Ec2 Ubunto.
I wouldn't trust this "nuodb" at all. Looks like a bubble.
You didn't install nuodb anyway, but mysql.
So - just go on with mysql!
#Sarun Prasomsri
What version of NuoDB are you running?
What version of PHP? (supported versions are PHP 5.4 TS VC9 and PHP 5.3 TS VC9)
# Your Common Sense
NuoDB does install - it can run on a localmachine, datacenter, or AWS/Azure/Google Compute, like any other Database.
There are concrete details in the online doc: http://doc.nuodb.com/display/doc/NuoDB+Online+Documentation
techblog: http://dev.nuodb.com/techblog

How to connect to a SQLite DB with Agile Toolkit 4?

I'd like to use SQLite3 with Agile Toolkit. I found it in the documentation that the SQLite driver is included with atk4, but I couldn't find any examples of how to connect to a SQLite DB.
I tried to change the DB connection of the example applications shipped with atk4 from MySql to SQLite using the format found in the Pear:DB DSN documentation:
$config['dsn']='sqlite:////var/www/webdev/atk4_example.db';
but I keep getting the could not find driver PDO error:
Application Error: Database Connection Failed
BaseException, code: 0
Additional information:
* PDO error: could not find driver
* DSN: :host=;dbname=;charset=utf8
/var/www/webdev/atk4/lib/DB.php:94
The SQLite PDO driver seems to be installed correctly on the server. Both the phpinfo() and an PHP/PDO/SQLite3 example page confirms that it works.
I'm learning Agile Toolkit, PHP and general web development, so I might be missing something trivial.
Can you try following syntax in your config.php?
$config['dsn']='sqlite://username:password#hostname/dbname';
Also please check if you have MySQL (yes, MySQL not SQLite) extension enabled in your php.ini. If not, then try to enable it and test again. If SQLite works with enabled MySQL extension then I guess I have found small bug in DB.php and could fix that.
Also it looks that you can pass DSN parameters in following format as array and maybe that's even better:
$config['dsn'] = array(
'sqlite:host=hostname;dbname=dbname;charset=utf8',
'username',
'password'
);
Please try 2 solutions described above and let me know if they work.
I can't test that myself now because I'm not at my developing computer.

Scrapy / Python and SQL Server

Is it possible to get the data scraped from websites using Scrapy, and saving that data in an Microsoft SQL Server Database?
If Yes, are there any examples of this being done? Is it mainly a Python issue? i.e. if I find some code of Python saving to an SQL Server database, then Scrapy can do same?
Yes, but you'd have to write the code to do it yourself since scrapy does not provide an item pipeline that writes to a database.
Have a read of the Item Pipeline page from the scrapy documentation which describes the process in more detail (here's a JSONWriterPipeline as an example). Basically, find some code that writes to a SQL Server database (using something like PyODBC) and you should be able to adapt that to create a custom item pipeline that outputs items directly to a SQL Server database.
Super late and completely self promotion here, but I think this could help someone. I just wrote a little scrapy extension to save scraped items to a database. scrapy-sqlitem
It is super easy to use.
pip install scrapy_sqlitem
Define Scrapy Items using SqlAlchemy Tables
from scrapy_sqlitem import SqlItem
class MyItem(SqlItem):
sqlmodel = Table('mytable', metadata
Column('id', Integer, primary_key=True),
Column('name', String, nullable=False))
Add the following pipeline
from sqlalchemy import create_engine
class CommitSqlPipeline(object):
def __init__(self):
self.engine = create_engine("sqlite:///")
def process_item(self, item, spider):
item.commit_item(engine=self.engine)
Don't forget to add the pipeline to settings file and create the database tables if they do not exist.
http://doc.scrapy.org/en/1.0/topics/item-pipeline.html#activating-an-item-pipeline-component
http://docs.sqlalchemy.org/en/rel_1_1/core/tutorial.html#define-and-create-tables

Resources