Moving Symfony Application Local Database to Web - symfony

I developed a application on my local system (Windows 7 & wamp)its working fine so I decided to deploy it to my shared hosting account
I create a blank database on server and then imported my local database file
but if try to login to my system I am getting table not found error although table are present in database
I am getting error like below
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'ezwebsto_ezwoms.WomsLog' doesn't exist") in
"AdminBundle:Default:home.html.twig
I suspect that the issue is because case sensitive table name, so renamed table name but still I am facing issue
can anyone guide me what is proper way to move local db of symfony application to web to p

MySQL on Windows by default is NOT case sensitive. On Unix based system it is.
The best practice is to turn on case sensitive in MySQL settings, and in future moving database to server will be simple.
You have to set up variable
lower_case_table_names = 0
in your my.ini file. On Windows, default value is 1.
But now, you have to map table name inside each entity, like wrote #prashant. Please compare table names with mapping names, and rename tables if necessary.
After change, your entity should look like:
/**
* Content
*
* #ORM\Table(name="content")
* #ORM\Entity()
*/
class Content
{
//some usefull code here
}

Just try to define the tablename in your entity class, with the Table annotation:
#ORM\Table(name="WomsLog")
As well make sure your table is correct in DB , W and L must be in upper case.

Related

SAP HANA custom dictionary: full-text-index not generated or updated

There are two problems with SAP HANA custom dictonaries.
Updating and recompiling the dictionary has no effect on the full-text-index table (even by dropping and generating the full-text-index again)
using custom dictionaries & configuration may lead to an empty fulltext-index-table
For the 1. Problem
deleting the configuration file and replace it with a new file (same content but different file name) then activating all changes (activates the deletion of the old config and adds the new config) seems to be a work-around.
Note: this means you also have to change the configuration name in the SQL command.
For the 2. Problem
Check this trace file:
/usr/sap/HDB/HDB00/hanadb/trace/preprocessor_alert_hanadb.trc
This error message:
File read Error '/usr/sap/HDB/SYS/global/hdb/custom/config/lexicon//EXTRACTION_CORE_MOD2', error='Storage object does not exist: $STORAGEOBJECT$'
occurs if the configuration file EXTRACTION_CORE_MOD2 is not properly activated in the repository under sap.hana.ta.config. So double check the repository if the configuration file exists in the specified path.
For the first problem, I have the same scenario in which I need to make some changes in the custom dictionary and activated it. It did not affect my index table unit I run the following statement:
ALTER INDEX MYINDEX REBUILD;
I have checked it and the changes affect the index table by this statement. So you do not have to remove your index or save the changes of your custom dictionary in a file with new name.

Can the Path assigned a SQLite DB be an arbitrary value?

In this blog post, some prerequisite code for getting started using SQLite in Windows Store Apps is given, for adding to the OnLaunched method of App.xaml.cs:
// Get a reference to the SQLite database
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "customers.sqlite");
My question is: Can I use any arbitrary value to replace the "customers.sqlite" part, or does it have to match something else in my code, such as the name of my table definition class (in my case "PhotraxCoreData.cs" which, according to Mr. Green's suggestion, I added below a newly-created "Models" folder)?
My understanding is that, once I've got those classes defined (I do), and the code above in App.xaml.cs, along with this there (adapted for my SQLite classes):
using (var db = new SQLite.SQLiteConnection(this.DBPath))
{
// Create the tables if they don't exist
db.CreateTable<PhotraxBaseData>();
db.CreateTable<PhotraxNames>();
db.CreateTable<PhotraxQueries>();
}
...SQLite tables based on those classes I specified will be created, and have the name "customers.sqlite" (provided I don't change it).
So, can I use:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "platypus.sqlite");
...or must it be something like:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "PhotraxCoreData.sqlite");
That database name is just a file name.
The directory must be accessible by your app, but the file name can be anything.
AS CL says, the file name can be anything the app has direct access to. Windows Store apps have limited access to the file system, so the sqlite database must be in either the apps install location (read only) or it's app data folder (read write). A common pattern is to ship a seed database in the app package and then copy it from the install location to app data on first use so it can be written to.

Using SQL Server 2012 Geography Data Type with ASP.Net - DataReader.GetFieldType(x) returned null

I've written an ASP.Net 4 Application which has been working perfectly. However, I decided to make use of the new Geography Data Type in Sql Sever 2012. This worked perfectly on my local machine but fails when I upload.
I get there error "DataReader.GetFieldType(9) returned null." when doing a usual "select * FROM Table" query on a table that contains one of these datatypes.
I have searched the various threads regarding adding a reference to the Microsoft.SqlServer.Types.dll into my project and changing Copy Local to true. However I am getting the same error.
I run the database and the web server on two separate servers so I don't think there are any assemblies on the web server unless I upload them with my project.
Am I missing any other assemblies that are needed? or any other settings?
I've taken days trying to solve this and uploading variouse libraries. Any help would be appreciated.
msdn
When the compatibility level is 100 or below in SQL Server 2012 then the geography data type has the following restrictions:
•Each geography instance must fit inside a single hemisphere. No spatial objects larger than a hemisphere can be stored.
•Any geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) or Well-Known Binary (WKB) representation that produces an object larger than a hemisphere throws an ArgumentException.
•The geography data type methods that require the input of two geography instances, such as STIntersection(), STUnion(), STDifference(), and STSymDifference(), will return null if the results from the methods do not fit inside a single hemisphere. STBuffer() will also return null if the output exceeds a single hemisphere.
From what I can tell you will at least need SQL Server installed locally when you initially add the reference. If you can I would try and install SQL Express locally first (you do not need to use it just install it) and then try your code again to see if that is the problem.
References:
DataReader.GetFieldType returned null
http://blogs.bing.com/maps/2013/08/05/advance-spatial-queries-using-entity-framework-5/
Edit:
I am more familiar with using spatial types via the entity framework. It seems if you want to use them directly you need to use a nuget package in order to get the required DLLs into the project. From the Microsoft ADO.NET blog page
SqlServerSpatial110.dll – This is a native assembly so it cannot be added as a project reference.
References:
Microsoft ADO.NET Blog
http://blogs.msdn.com/b/adonet/archive/2013/12/09/microsoft-sqlserver-types-nuget-package-spatial-on-azure.aspx
Relevant SO Questions
'Microsoft.SqlServer.Types' version 10 or higher could not be found on Azure
https://gis.stackexchange.com/questions/382/how-can-i-use-sql-servers-spatial-types-from-a-net-application
Spent heaps of time on this, adding references as well, but I found a workaround i want to share.
Should work fine on asp.net as well.
I use the following query to parse me the string representation of the object:
DECLARE #result geography;
SELECT #result = area FROM news WHERE id LIKE #id ;
SELECT ..., #result.STAsText() as area FROM news WHERE id LIKE #id;
And in the asmx (c#) webservice i retrieved my SQLGeography with a parser method:
row["area"].ToString()
After that you can use a parser method to retrieve the SQLGeography object.
/// <summary>
/// Converts a String into an sql geography object.</summary>
/// <param name="pText">The string representation of the sql geography object. </param>
public static SqlGeography GetGeographyFromText(String pText)
{
SqlString ss = new SqlString(pText);
SqlChars sc = new SqlChars(ss);
try
{
if (pText.Contains("POINT"))
{
return SqlGeography.STPointFromText(sc, 4326);
}
return SqlGeography.STPolyFromText(sc, 4326);
}
catch (Exception ex)
{
return SqlGeography.STMPolyFromText(sc, 4326);
throw ex;
}
}
Hope it helps anyone!
In the end I couldn't get it to work as it does on my development machine and I don't want to install Visual Studio or SQL Server Express on the web server so instead I just removed all the queries where I did "SELECT * FROM Table" and the error went away. It still let me do my calculations using the geography field, but doesn't like you trying to show it on the screen. Thanks for all your help!

SQL Server Deploy Script

I use sql server 2005 for an asp.net project. I want to run a SQL file that contains all DB changes from the last release to easily bring a DB up to the latest version.
I basically just have a bunch of alter table, create table, create index, alter view, call stored proc, etc statements. But I would like to wrap it in a transaction so if any part of it fails, none of the changes will go through. Otherwise it could make for some really messy debugging where it finished.
Also, if you know of a better way to manage DB deployment let me know!
I do something similar with a Powershell script using SMO.
Pseudocode would be:
$SDB = SourceDBObject
$TDB = TargetDBObject
ForEach $table in $SDB.Tables
{
Add an entry to a hash table with the name
and some attributes (rowcount, columns, datasize)
}
# Same thing for $TDB
# Compare the two arrays, and make a list of all the ones that exist in the source but not in the target, or that are different
# Same thing for Procs and Views
# Pass this list to a SMO.Scripter as an UrnCollection object, and it will script them out in dependency order (it's an option), with drops
# Wrap the script in a transaction and execute it on target server
# Use SQLBulkCopy class to transfer data server-to-server
What version of Visual Studio do you use? In Visual Studio 2010 and from what I can remember Visual Studio 2008 - in the menu under "Data" there are two options - "Schema Compare" and "Data Compare". That should move you in the right direction.
BEGIN TRANSACTION #TranName;
USE AdventureWorks2008R2;
DELETE FROM AdventureWorks2008R2.HumanResources.JobCandidate
WHERE JobCandidateID = 13;
COMMIT TRANSACTION #TranName;
You should execute everything within a transaction
Note that some DDL statements have to be the first statement in a batch (batches are separate from transactions). (GO is the default batch separator in SSMS and SQLCMD).

Schema qualified tables with SQLAlchemy, SQLite and Postgresql?

I have a Pylons project and a SQLAlchemy model that implements schema qualified tables:
class Hockey(Base):
__tablename__ = "hockey"
__table_args__ = {'schema':'winter'}
hockey_id = sa.Column(sa.types.Integer, sa.Sequence('score_id_seq', optional=True), primary_key=True)
baseball_id = sa.Column(sa.types.Integer, sa.ForeignKey('summer.baseball.baseball_id'))
This code works great with Postgresql but fails when using SQLite on table and foreign key names (due to SQLite's lack of schema support)
sqlalchemy.exc.OperationalError: (OperationalError) unknown database "winter" 'PRAGMA "winter".table_info("hockey")' ()
I'd like to continue using SQLite for dev and testing.
Is there a way of have this fail gracefully on SQLite?
I'd like to continue using SQLite for
dev and testing.
Is there a way of have this fail
gracefully on SQLite?
It's hard to know where to start with that kind of question. So . . .
Stop it. Just stop it.
There are some developers who don't have the luxury of developing on their target platform. Their life is a hard one--moving code (and sometimes compilers) from one environment to the other, debugging twice (sometimes having to debug remotely on the target platform), gradually coming to an awareness that the gnawing in their gut is actually the start of an ulcer.
Install PostgreSQL.
When you can use the same database environment for development, testing, and deployment, you should.
Not to mention the QA team. Why on earth are they testing stuff they're not going to ship? If you're deploying on PostgreSQL, assure the quality of your work on PostgreSQL.
Seriously.
I'm not sure if this works with foreign keys, but someone could try to use SQLAlchemy's Multi-Tenancy Schema Translation for Table objects. It worked for me but I have used custom primaryjoin and secondaryjoinexpressions in combination with composite primary keys.
The schema translation map can be passed directly to the engine creator:
...
if dialect == "sqlite":
url = lambda: "sqlite:///:memory:"
execution_options={"schema_translate_map": {"winter": None, "summer": None}}
else:
url = lambda: f"postgresql://{user}:{pass}#{host}:{port}/{name}"
execution_options=None
engine = create_engine(url(), execution_options=execution_options)
...
Here is the doc for create_engine. There is a another question on so which might be related in that regard.
But one might get colliding table names all schema names are mapped to None.
I'm just a beginner myself, and I haven't used Pylons, but...
I notice that you are combining the table and the associated class together. How about if you separate them?
import sqlalchemy as sa
meta = sa.MetaData('sqlite:///tutorial.sqlite')
schema = None
hockey_table = sa.Table('hockey', meta,
sa.Column('score_id', sa.types.Integer, sa.Sequence('score_id_seq', optional=True), primary_key=True),
sa.Column('baseball_id', sa.types.Integer, sa.ForeignKey('summer.baseball.baseball_id')),
schema = schema,
)
meta.create_all()
Then you could create a separate
class Hockey(Object):
...
and
mapper(Hockey, hockey_table)
Then just set schema above = None everywhere if you are using sqlite, and the value(s) you want otherwise.
You don't have a working example, so the example above isn't a working one either. However, as other people have pointed out, trying to maintain portability across databases is in the end a losing game. I'd add a +1 to the people suggesting you just use PostgreSQL everywhere.
HTH, Regards.
I know this is a 10+ year old question, but I ran into the same problem recently: Postgres in production and sqlite in development.
The solution was to register an event listener for when the engine calls the "connect" method.
#sqlalchemy.event.listens_for(engine, "connect")
def connect(dbapi_connection, connection_record):
dbapi_connection.execute('ATTACH "your_data_base_name.db" AS "schema_name"')
Using ATTACH statement only once will not work, because it affects only a single connection. This is why we need the event listener, to make the ATTACH statement over all connections.

Resources